<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2019/09/06
 * Time: 13:29
 */

namespace App\Tools\Astrolog;

use App\Tools\Util;
use App\Models\Api\SyzygyTIme;
use Exception;
use Log;

/**
 * 计算用户本命预测
 * Class NatalReport
 * @package App\Tools\Astrolog
 */
class NatalReport
{
    /**
     * 单例
     * @var NatalReport
     */
    protected static $instance;
    /**
     * 计算报告时产生的错误信息
     * @var string
     */
    protected $error = '';
    /**
     * 用户本命星盘数据
     * @var array
     */
    protected $astroData = [];
    /**
     * 用户档案信息
     * @var array
     */
    protected $recode = [];
    /**
     * 是否获取用户本命财富报告
     * 0 不获取
     * 1 获取
     * @var int
     */
    protected $getMoneyReport = 0;
    /**
     * 是否获取用户本命感情报告
     * 0 不获取
     * 1 获取
     * @var int
     */
    protected $getFeelingsReport = 0;
    /**
     * 是否获取用户本命婚恋报告
     * 0 不获取
     * 1 获取
     * @var int
     */
    protected $getDatingReport = 0;
    /**
     * 是否获取用户本命事业报告
     * 0 不获取
     * 1 获取
     * @var int
     */
    protected $getCarrerReport = 0;
    /**
     * 是否获取用户本命学业报告
     * 0 不获取
     * 1 获取
     * @var int
     */
    protected $getAcademicReport = 0;
    /**
     * 用户太阳返照数据
     * @var array
     */
    protected $solarReturnData = [];
    /**
     * 用户法达盘数据
     * @var array
     */
    protected $firdariaData = [];
    /**
     * 用户次限VS本命盘数据
     * @var array
     */
    protected $progressionsvsnatalData = [];
    /**
     * 财富报告相关设置
     * @var array
     */
    protected $setting1 = [
        'natal' => [
            'planet' => [
                [1, 8.5], [1, 7.5], [1, 3.5], [1, 3.5], [1, 4], [1, 4.5], [1, 4.5], [1, 2.5], [1, 2.5], [1, 2.5],
                [0, 0], [0, 0], [0, 0], [0, 0], [1, 2.5], [0, 0], [0, 0], [1, 2.5], [1, 2.5], [1, 2.5], [1, 2.5]
            ],
            'phase' => [
                0 => [1, 0], 60 => [1, 0], 90 => [1, 0], 120 => [1, 0], 180 => [1, 0],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [0, 0], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'default',
            'bound_type' => 'default',
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,
            'ayanamsa' => 0,
            'location_use' => 0
        ],
    ];
    /**
     * 恋爱报告相关设置
     * @var array
     */
    protected $setting2 = [
        'solar_return' => [
            'planet' => [
                [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'phase' => [
                0 => [1, 6], 60 => [1, 3], 90 => [1, 5], 120 => [1, 5], 180 => [1, 5],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [0, 0], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'default',
            'bound_type' => 'default',
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,
            'ayanamsa' => 0,
            'location_use' => 0
        ]
    ];
    /**
     * 事业报告相关设置
     * @var array
     */
    protected $setting3 = [
        'natal' => [
            'planet' => [
                [1, 8.5], [1, 7.5], [1, 3.5], [1, 3.5], [1, 4], [1, 4.5], [1, 4.5], [1, 2.5], [1, 2.5], [1, 2.5],
                [0, 0], [0, 0], [1, 2.5], [0, 0], [1, 2.5], [0, 0], [0, 0], [1, 2.5], [1, 2.5], [1, 2.5], [1, 2.5]
            ],
            'phase' => [
                0 => [1, 0], 60 => [1, 0], 90 => [1, 0], 120 => [1, 0], 180 => [1, 0],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [0, 0], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'default',
            'bound_type' => 'default',
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,
            'ayanamsa' => 0,
            'location_use' => 0
        ],
        'firdaria' => [
            'planet' => [
                [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [1, 0], [1, 0], [0, 0], [0, 0], [1, 0]
            ],
            'phase' => [
                0 => [1, 6], 60 => [1, 3], 90 => [1, 5], 120 => [1, 5], 180 => [1, 5],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [1, 1.5], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'another',// 月交点在水星后
            'bound_type' => 'default',// 埃及界
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,// 欧洲古典
            'ayanamsa' => 0,
            'location_use' => 0
        ]
    ];
    /**
     * 婚姻报告相关设置
     * @var array
     */
    protected $setting4 = [
        'natal' => [
            'planet' => [
                [1, 8.5], [1, 7.5], [1, 3.5], [1, 3.5], [1, 4], [1, 4.5], [1, 4.5], [1, 2.5], [1, 2.5], [1, 2.5],
                [0, 0], [0, 0], [1, 2.5], [1, 2.5], [1, 2.5], [0, 0], [0, 0], [1, 2.5], [1, 2.5], [1, 2.5], [1, 2.5]
            ],
            'phase' => [
                0 => [1, 0], 60 => [1, 0], 90 => [1, 0], 120 => [1, 0], 180 => [1, 0],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [0, 0], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'default',
            'bound_type' => 'default',
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,
            'ayanamsa' => 0,
            'location_use' => 0
        ],
        'firdaria' => [
            'planet' => [
                [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0], [1, 0], [1, 0], [0, 0], [0, 0], [1, 0]
            ],
            'phase' => [
                0 => [1, 6], 60 => [1, 3], 90 => [1, 5], 120 => [1, 5], 180 => [1, 5],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [1, 1.5], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'another',// 月交点在水星后
            'bound_type' => 'default',// 埃及界
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,// 欧洲古典
            'ayanamsa' => 0,
            'location_use' => 0
        ],
        'progressionsvsnatal' => [
            'planet' => [
                [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5], [1, 1.5],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [1, 1.5], [0, 1.5], [0, 1.5], [1, 1.5]
            ],
            'phase' => [
                0 => [1, 0], 60 => [1, 0], 90 => [1, 0], 120 => [1, 0], 180 => [1, 0],
                45 => [0, 0], 135 => [0, 0], 30 => [0, 0], 150 => [0, 0], 72 => [0, 0], 144 => [0, 0]
            ],
            'arabic' => [
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
                [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]
            ],
            'h_sys' => 'p',
            'firdaria' => 'default',
            'bound_type' => 'default',
            'ecliptic' => 0,
            'profection_push_direction' => 0,
            'decanates' => 0,
            'ayanamsa' => 0,
            'location_use' => 0
        ],
    ];

    /**
     * 构造方法
     * 单例模式，私有化
     * 只能通过 getInstance 公共方法获取实例
     * NatalReport constructor.
     */
    private function __construct()
    {
    }

    /**
     * 获取实例
     * @return NatalReport
     */
    public static function getInstance(): NatalReport
    {
        if (!(self::$instance instanceof self))
        {
            self::$instance = new self();
        }
        return self::$instance;
    }

    /**
     * 设置用户本命星盘数据
     * @param array $data
     * @return $this
     */
    public function setAstroData(array $data = []): self
    {
        $this->astroData = $data;
        return $this;
    }

    /**
     * 设置用户档案的信息
     * @param array $data
     * @return $this
     */
    public function setUserRecode(array $data = []): self
    {
        if (!empty($data))
        {
            $this->recode = $data;
        }
        return $this;
    }

    /**
     * 设置是否获取财富报告
     * @param bool $status
     * @return NatalReport
     */
    public function setMoneyReportStatus(bool $status = false): NatalReport
    {
        $this->getMoneyReport = $status === true;
        return $this;
    }

    /**
     * 设置是否获取感情报告
     * @param bool $status
     * @return NatalReport
     */
    public function setFeelingsReportStatus(bool $status = false): NatalReport
    {
        $this->getFeelingsReport = $status === true;
        return $this;
    }

    /**
     * 设置是否获取婚恋报告
     * @param bool $status
     * @return NatalReport
     */
    public function setDatingReportStatus(bool $status = false): NatalReport
    {
        $this->getDatingReport = $status === true;
        return $this;
    }

    /**
     * 设置是否获取事业报告
     * @param bool $status
     * @return NatalReport
     */
    public function setCarrerReportStatus(bool $status = false): NatalReport
    {
        $this->getCarrerReport = $status === true;
        return $this;
    }

    /**
     * 设置是否获取学业报告
     * @param bool $status
     * @return NatalReport
     */
    public function setAcademicReportStatus(bool $status = false): NatalReport
    {
        $this->getAcademicReport = $status === true;
        return $this;
    }

    /**
     * 批量进行配置
     * @param array $config
     * @return NatalReport
     */
    public function setConfig(array $config = []): NatalReport
    {
        if (isset($config['astroData']) && !empty($config['astroData']))
        {
            $this->setAstroData($config['astroData']);
        }
        if (isset($config['getReports']) && !empty($config['getReports']))
        {
            $this->setMoneyReportStatus($config['getReports']['money'] === true);
            $this->setFeelingsReportStatus($config['getReports']['feelings'] === true);
            $this->setDatingReportStatus($config['getReports']['dating'] === true);
            $this->setCarrerReportStatus($config['getReports']['carrer'] === true);
            $this->setAcademicReportStatus($config['getReports']['academic'] === true);
        }
        return $this;
    }

    /**
     * 获取所需用户本命预测
     * @param string $reportName
     * @return array|false
     */
    public function getReports(string $reportName = '')
    {
        $data = [];
        // 获取本命财富报告
        if ($this->getMoneyReport)
        {
            $moneyReportData = $this->getMoneyReportData();
            $data['money'] = $moneyReportData;
        }
        // 获取本命感情报告
        if ($this->getFeelingsReport)
        {
            $feelingsReportData = $this->getFeelingsReportData();
            $data['feelings'] = $feelingsReportData;
        }
        // 获取本命婚恋报告
        if ($this->getDatingReport)
        {
            $datingReportData = $this->getDatingReportData();
            $data['dating'] = $datingReportData;
        }
        // 获取本命事业报告
        if ($this->getCarrerReport)
        {
            $carrerReportData = $this->getCarrerReportData();
            $data['carrer'] = $carrerReportData;
        }
        // 获取本命学业报告
        if ($this->getAcademicReport)
        {
            $academicReportData = $this->getAcademicReportData();
            $data['academic'] = $academicReportData;
        }
        if ($reportName && isset($data[$reportName]))
        {
            return $data[$reportName];
        }

        return $data;
    }

    /**
     * 获取错误信息
     * @return string
     */
    public function getError(): string
    {
        return $this->error;
    }

    /**
     * 计算用户的星盘数据（计算报告专用）
     * @param array $setting 计算星盘数据时，使用的设置
     * @return $this
     */
    private function getNatalData($setting = []): self
    {
        if (!empty($this->recode))
        {
            $this->astroData = [];
            $data = Astrolog::getInstance()
                ->setRecode1($this->recode)
                ->setExecPrefix(config('astrolog.prefix'))
                ->setIsAstrolabe(true)
                ->setUserSetting($setting)
                ->setVersion(2)
                ->setGetDatas(['natal'])
                ->getAstroDatas()
                ->getDatas('natal');

            $this->astroData = json_decode(json_encode($data), true);
        }
        return $this;
    }

    /**
     * 获取法达盘数据
     * @param array $setting 计算星盘数据时，使用的设置
     * @param int $startYearsOld
     * @param int $endYearsOld
     * @return $this
     */
    private function getFirdariaData($setting = [], $startYearsOld = 12, $endYearsOld = 100): self
    {
        // 初始化法达数据
        $this->firdariaData = [];
        $Astrolog = Astrolog::getInstance()->setRecode1($this->recode)->setUserSetting($setting)->setGetDatas(['firdaria']);
        $recode = $Astrolog->getRecode1();
        $startYearsOld--;
        // 从12岁开始
        $recode['year'] += $startYearsOld;
        $end = $endYearsOld - $startYearsOld;
        for ($i = 0; $i < $end; $i++)
        {
            $recode['year']++;
            $tmp = $Astrolog->setAdvance($recode)->setIsAstrolabe(false)->getAstroDatas()->getDatas('firdaria');

            $this->firdariaData[$i] = [
                'planets' => $tmp['planets'],
                'houses' => $tmp['houses'],
                'firdaria' => $tmp['firdaria']
            ];
        }
        return $this;
    }

    /**
     * 获取次限VS本命盘设置
     * progressionsvsnatal
     * @param array $setting 计算星盘数据时，使用的设置
     * @param int $startYearsOld
     * @param int $endYearsOld
     * @return $this
     */
    private function getProgressionsvsnatalData($setting = [], $startYearsOld = 18, $endYearsOld = 80): self
    {
        $Astrolog = Astrolog::getInstance()->setRecode1($this->recode)->setUserSetting($setting)->setGetDatas(['progressionsvsnatal']);
        $recode = $Astrolog->getRecode1();
        $startYearsOld--;
        // 从12岁开始
        $recode['year'] += $startYearsOld;
        $end = $endYearsOld - $startYearsOld;
        $this->progressionsvsnatalData = [];
        for ($i = 0; $i < $end; $i++)
        {
            $recode['year']++;
            $tmp = $Astrolog->setAdvance($recode)->setIsAstrolabe(false)->getAstroDatas()->getDatas('progressionsvsnatal');
            // 次限VS本命 [0 => 本命,1 => 次限]
            $this->progressionsvsnatalData[$i] = [
                'planets' => $tmp[1]['planets'],
                'houses' => $tmp[1]['houses'],
            ];
        }
        return $this;
    }

    /**
     * 获取本命财富报告
     * @return array|false
     */
    protected function getMoneyReportData()
    {
        try
        {
            $this->getNatalData(['natal' => $this->setting1['natal']]);
            $this->getFirdariaData(['firdaria' => $this->setting3['firdaria']]);
            $result = [];
            $result['text'][] = $this->getMoneyCurveData();
            $result['text'][] = $this->getMoneySection1();
            $result['text'][] = $this->getMoneySection2();
            $result['text'][] = $this->getMoneySection3();
        }
        catch (Exception $e)
        {
            $this->error .= '[' . $e->getMessage() . '] ' . $e->getFile() . ':' . $e->getLine();
            return false;
        }
        return $result;
    }

    /**
     * 获取本命感情报告
     * @return array|false
     */
    protected function getFeelingsReportData()
    {
        try
        {
            $this->getNatalData(['natal' => $this->setting1['natal']]);
            $result = [];
            $result['text'][] = $this->getFeelingsCurveData();
            $result['text'][] = $this->getFeelingsSection1();
            $result['text'][] = $this->getFeelingsSection2();
            $result['text'][] = $this->getFeelingsSection3();
            $result['text'][] = $this->getFeelingsSection4();
//            unset($result['text'][0]['content_list'], $result['text'][1]['content_list'], $result['text'][2]['content_list'], $result['text'][3]['content_list'], $result['text'][4]['content_list']);

            //图1:减40  （如果大于100，封顶100）
            //其余：
            //如果小于1000，+1000) /40 取整
            //如果大于2000，-1000) /40取整
            //大于等于1000小于等于2000，/40取整
            foreach ($result['text'][0]['levels'] as $lk => $ld)
            {
                $ld -= 40;
                if ($ld > 100)
                {
                    $ld = 100;
                }
                $result['text'][0]['levels'][$lk] = $ld;
            }

            foreach ($result['text'][1]['levels'] as $lk => $ld)
            {
                $t = $ld - floor($ld / 1000 - 1) * 1000;
                $t = round($t / 40);
                $lv = 1;
                if ($t > 80)
                {
                    $lv = 5;
                } elseif ($t > 60)
                {
                    $lv = 4;
                } elseif ($t > 40)
                {
                    $lv = 3;
                } elseif ($t > 20)
                {
                    $lv = 2;
                }
                $result['text'][1]['levels'][$lk] = $lv;

            }

            foreach ($result['text'][3]['levels'] as $lk => $ld)
            {
                $t = $ld - floor($ld / 1000 - 1) * 1000;
                $t = round($t / 40);
                $lv = 1;
                if ($t > 80)
                {
                    $lv = 5;
                } elseif ($t > 60)
                {
                    $lv = 4;
                } elseif ($t > 40)
                {
                    $lv = 3;
                } elseif ($t > 20)
                {
                    $lv = 2;
                }
                $result['text'][3]['levels'][$lk] = $lv;
            }
        }
        catch (Exception $e)
        {
            $this->error .= '[' . $e->getMessage() . '] ' . $e->getFile() . ':' . $e->getLine();
            return false;
        }
        return $result;
    }

    /**
     * 获取本命婚姻报告
     * @return array|false
     */
    protected function getDatingReportData()
    {
        try
        {
            $this->getNatalData(['natal' => $this->setting4['natal']])
                ->getFirdariaData(['firdaria' => $this->setting4['firdaria']], 20, 80)
                ->getProgressionsvsnatalData(['progressionsvsnatal' => $this->setting4['progressionsvsnatal']], 20, 80);
            $result = [];
            $result['text'][] = $this->getDatingCurveData();
            $result['text'][] = $this->getDatingReportSection1();
            $result['text'][] = $this->getDatingReportSection2();
            $result['text'][] = $this->getDatingReportSection3();
            $result['text'][] = $this->getDatingReportSection4($result['text'][0]['levels']);
            $result['text'][] = $this->getDatingReportSection5();
        }
        catch (\Exception $e)
        {
            $this->error .= '[' . $e->getMessage() . '] ' . $e->getFile() . ':' . $e->getLine();
            return false;
        }
        return $result;
    }

    /**
     * 获取本命事业报告
     * @return array|false
     */
    protected function getCarrerReportData()
    {
        try
        {
            $this->getNatalData(['natal' => $this->setting1['natal']])
                ->getFirdariaData(['firdaria' => $this->setting3['firdaria']]);
            $result = [];
            $result['text'][] = $this->getCarrerCurveData();
            $result['text'][] = $this->getCarrerReportSection1();
            $result['text'][] = $this->getCarrerReportSection2();
            $result['text'][] = $this->getCarrerReportSection3();
            $result['text'][] = $this->getCarrerReportSection4();
            $result['text'][] = $this->getCarrerReportSection5();
        }
        catch (Exception $e)
        {
            $this->error .= '[' . $e->getMessage() . '] ' . $e->getFile() . ':' . $e->getLine();
            return false;
        }
        return $result;
    }

    /**
     * 获取本命学业报告
     * @return array|false
     */
    protected function getAcademicReportData()
    {
        try
        {
            // 本命盘配置延用事业配置
            $this->getNatalData(['natal' => $this->setting3['natal']])
                ->getFirdariaData(['firdaria' => $this->setting3['firdaria']], 6, 100);
            $result = [];
            $result['text'][] = $this->getAcademicCurveData();
            $result['text'][] = $this->getAcademicReportSection1();
            $result['text'][] = $this->getAcademicReportSection2();
            $result['text'][] = $this->getAcademicReportSection3();
            $result['text'][] = $this->getAcademicReportSection4();
            $result['text'][] = $this->getAcademicReportSection5();
            $result['text'][] = $this->getAcademicReportSection6();
        }
        catch (Exception $e)
        {
            $this->error .= '[' . $e->getMessage() . '] ' . $e->getFile() . ':' . $e->getLine();
            return false;
        }
        return $result;
    }

    /**
     * 图 1：一生财富曲线图(20-70岁)
     * @return array
     */
    private function getMoneyCurveData()
    {
        //法达星限
        //P1主限运：日、金、水、月、土、木、火
        //P2副限运：日、金、水、月、土、木、火
        //年份得分计算公式：P1*0.3+P2*0.7
        $levels = [];
        // 用本命盘计算行星互容接纳数据
        $receptOrMutualRecept = $this->astroData['characteristic'];
        foreach ($this->firdariaData as $k => $firdaria)
        {
            $main = $firdaria['firdaria']['main_luck'];
            $sub = $firdaria['firdaria']['sub_luck'];

            $p1 = $this->getMainOrSubScore($main, $firdaria, $receptOrMutualRecept);
            $p2 = $this->getMainOrSubScore($sub, $firdaria, $receptOrMutualRecept);

            $score = $p1 * 0.3 + $p2 * 0.7;
            $levels[] = (string)$score;
        }
        $result = [
            'desc' => '图 1：一生财富曲线图',
            'content_list' => [],
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 获取财富报告曲线图 p1 p2分数
     * @param null $pid 大运 || 小运 行星id
     * @param array $firdaria 法达盘数据
     * @param array $receptOrMutualRecept 本命行星互容接纳数据
     * @return int
     */
    private function getMainOrSubScore($pid = null, $firdaria = [], $receptOrMutualRecept = [])
    {
        $house2ProtectAncient = $firdaria['houses'][2]['protect_ancient_id'];
        $pidIsVenuOrJupi = in_array($pid, [3, 5], true);
        $pidIsMarsOrSatu = in_array($pid, [4, 6], true);
        // 金星的尊贵禀赋
        $venuAncientPower = $firdaria['planets'][3]['ancient']['power'];
        if ($firdaria['planets'][3]['ancient']['migration'])
        {
            $venuAncientPower += 5;
        }
        // 火星的尊贵禀赋
        $marsAncientPower = $firdaria['planets'][4]['ancient']['power'];
        if ($firdaria['planets'][4]['ancient']['migration'])
        {
            $marsAncientPower += 5;
        }
        // 木星的尊贵禀赋
        $jupiAncientPower = $firdaria['planets'][5]['ancient']['power'];
        if ($firdaria['planets'][5]['ancient']['migration'])
        {
            $jupiAncientPower += 5;
        }
        // 土星的尊贵禀赋
        $satuAncientPower = $firdaria['planets'][6]['ancient']['power'];
        if ($firdaria['planets'][6]['ancient']['migration'])
        {
            $satuAncientPower += 5;
        }
        //【P计分方式】
        //增加日月水金火木土，基础分值： 20191218 edit by seunk
        //日+3 分、月+3 分、金+5 分、木+5 分、火+2 分、水+2 分、土+1、南交+1，北交+1
        $basePower = [3, 3, 2, 5, 2, 5, 1, 12 => 1, 16 => 1];
        //①日、金、水、月、土、木、火尊贵禀赋得分（+5、+4、+3、+2、+1、-5、-4），游走计 0 分
        // 南交双子-4 南交射手+4 北交双子+4 北交射手-4 其它为 0
        $p = $firdaria['planets'][$pid]['ancient']['power'] + $basePower[$pid];
        switch ($pid)
        {
            // 北交点
            case 12:
                if ($firdaria['planets'][$pid]['in_sign_id'] === 3)
                {
                    $p = 4;
                } elseif ($firdaria['planets'][$pid]['in_sign_id'] === 9)
                {
                    $p = -4;
                }
                break;
            // 南交点
            case 16:
                if ($firdaria['planets'][$pid]['in_sign_id'] === 3)
                {
                    $p = -4;
                } elseif ($firdaria['planets'][$pid]['in_sign_id'] === 9)
                {
                    $p = 4;
                }
                break;
            default:
                // 游走记0分
                if ($firdaria['planets'][$pid]['ancient']['migration'])
                {
                    $p = 0;
                }
                break;
        }
        //⑪若该主限运行星为南北交
        if ($pid === 12 || $pid === 16)
        {
            //A、看与之会合行星是否满足其他 个条件
            if (!empty($firdaria['planets'][$pid]['phase']))
            {
                foreach ($firdaria['planets'][$pid]['phase'] as $phase)
                {
                    if ($phase['phase_e'] === 0 && $phase['id'] < 7)
                    {
                        $p += $this->getMainOrSubScore($phase['id'], $firdaria, $receptOrMutualRecept);
                    }
                }
            }
            //B、看其定位行星是否满足其他 个条件
            $nPid = $firdaria['houses'][$firdaria['planets'][$pid]['in_house_id']]['protect_ancient_id'];
            return $p + $this->getMainOrSubScore($nPid, $firdaria, $receptOrMutualRecept);
        }
//        //②若该主限行星为金、木，+1 分
//        if ($pidIsVenuOrJupi)
//        {
//            $p++;
//        } //③若该主限行星为火、土，-1 分
//        elseif ($pidIsMarsOrSatu)
//        {
//            $p--;
//        }
        //⑤若该主限运行星落 2 宫内，金木+1、日月水+0、火土-1
        if ($firdaria['planets'][$pid]['in_house_id'] === 2)
        {
            if ($pidIsVenuOrJupi)
            {
                $p++;
            } elseif ($pidIsMarsOrSatu)
            {
                $p--;
            }
        }
        //⑥若该主限运行星接纳/互容金木（接纳指产生接纳关系即可，不区分主动被动）
        $pidRemrVenu = false;
        $pidRemrJupi = false;
        $pidRemrSatu = false;//  20191219 edit by seunk
        $house2ProtectAncientRemrVenu = false;
        $house2ProtectAncientRemrMars = false;
        $house2ProtectAncientRemrJupi = false;
        $house2ProtectAncientRemrSatu = false;
        $pidRemrHouse2ProtectAncient = false;
        if (!empty($receptOrMutualRecept))
        {
            foreach ($receptOrMutualRecept as $r => $remr)
            {
                if ($r <= 2 && !empty($remr))
                {
                    foreach ($remr as $rm)
                    {
                        // 行星与金星产生接纳or互容关系
                        if (!$pidRemrVenu && (($rm['id1'] === 3 && $pid === $rm['id2'])
                                || ($rm['id2'] === 3 && $pid === $rm['id1'])))
                        {
                            $pidRemrVenu = true;
                            //a、金、木尊贵禀赋得分大于等于3分，+3 分
                            //a、金、木尊贵禀赋得分≥3分，+5分  20191218 edit by seunk
                            if ($venuAncientPower >= 3)
                            {
                                $p += 5;
                            }//b、金、木尊贵禀赋得分大于等于 0 分，+1 分
                            //b、3分＜金、木尊贵禀赋得分≤0 分，+3 分 20191218 edit by seunk
                            elseif ($venuAncientPower >= 0)
                            {
                                $p += 3;
                            }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                            else
                            {
                                $p--;
                            }
                        }
                        // 行星与木星产生接纳or互容关系
                        if (!$pidRemrJupi && (($rm['id1'] === 5 && $pid === $rm['id2'])
                                || ($rm['id2'] === 5 && $pid === $rm['id1'])))
                        {
                            $pidRemrJupi = true;
                            //a、金、木尊贵禀赋得分大于等于3分，+3 分
                            //a、金、木尊贵禀赋得分≥3分，+5分  20191218 edit by seunk
                            if ($jupiAncientPower >= 3)
                            {
                                $p += 5;
                            }//b、金、木尊贵禀赋得分大于等于 0 分，+1 分
                            //b、3分＜金、木尊贵禀赋得分≤0 分，+3 分 20191218 edit by seunk
                            elseif ($jupiAncientPower >= 0)
                            {
                                $p += 3;
                            }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                            else
                            {
                                $p--;
                            }
                        }
//                        // 行星与土星产生接纳or互容关系  20191219 edit by seunk
//                        if (!$pidRemrSatu && (($rm['id1'] === 6 && $pid === $rm['id2'])
//                                || ($rm['id2'] === 6 && $pid === $rm['id1'])))
//                        {
//                            $pidRemrSatu = true;
//                            //a、土星尊贵禀赋得分≥3分，+3分  20191219 edit by seunk
//                            if ($jupiAncientPower >= 3)
//                            {
//                                $p += 5;
//                            }//b、3分＜土星尊贵禀赋得分≤0 分，+3 分 20191219 edit by seunk
//                            elseif ($jupiAncientPower >= 0)
//                            {
//                                $p += 3;
//                            }//c、土星尊贵禀赋得分小于 0 分，-1 分
//                            else
//                            {
//                                $p--;
//                            }
//                        }
                        // 2宫主与金星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrVenu && (($rm['id1'] === 3 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 3 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrVenu = true;
                        }
                        // 2宫主与火星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrMars && (($rm['id1'] === 4 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 4 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrMars = true;
                        }
                        // 2宫主与木星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrJupi && (($rm['id1'] === 5 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 5 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrJupi = true;
                        }
                        // 2宫主与土星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrSatu && (($rm['id1'] === 6 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 6 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrSatu = true;
                        }
                        // 行星与2宫主产生接纳or互容关系
                        if (!$pidRemrHouse2ProtectAncient && (($rm['id1'] === $pid && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === $pid && $house2ProtectAncient === $rm['id1'])))
                        {
                            $pidRemrHouse2ProtectAncient = true;
                        }
                    }
                }
            }
        }
        //⑦若该主限运行星是2R 主，
        if ($pid === $house2ProtectAncient)
        {
            //④若该主限运行星是2R 主，+2分 // 20191205 +5分
            $p += 5;
            //A、当2R 主接纳/互容金、木 （只计金木各一次）
            if ($house2ProtectAncientRemrVenu)
            {
                //a、金、木尊贵禀赋得分大于等于3分，+4 分
                // +5 20191217 edit by seunk
                if ($venuAncientPower >= 3)
                {
                    $p += 5;
                }//b、金、木尊贵禀赋得分大于等于 0 分，+2 分
                // +3 20191217 edit by seunk
                elseif ($venuAncientPower >= 0)
                {
                    $p += 3;
                }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                else
                {
                    $p--;
                }
            }
            if ($house2ProtectAncientRemrJupi)
            {
                //a、金、木尊贵禀赋得分大于等于3分，+4 分
                // +5 20191217 edit by seunk
                if ($jupiAncientPower >= 3)
                {
                    $p += 5;
                }//b、金、木尊贵禀赋得分大于等于 0 分，+2 分
                // +3 20191217 edit by seunk
                elseif ($jupiAncientPower >= 0)
                {
                    $p += 3;
                }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                else
                {
                    $p--;
                }
            }
            //B、当2R主被火土天海冥刑克，-3 分 （只计一次）
            //刑克（90/180），火星-1 分，土星-2 分，天海冥-3 分 （各计一次） 20191218 edit by seunk
            //吉象（0/60/120）,火星+2分，土星+1 分，天海冥+0 分（各计一次）
            $house2ProtectAncientPhase4 = $house2ProtectAncient . '-' . 4;
            $house2ProtectAncientPhase6 = $house2ProtectAncient . '-' . 6;
            $house2ProtectAncientPhase7 = $house2ProtectAncient . '-' . 7;
            $house2ProtectAncientPhase8 = $house2ProtectAncient . '-' . 8;
            $house2ProtectAncientPhase9 = $house2ProtectAncient . '-' . 9;
            if (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase4]))
            {
                if (in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase4]['phase_e'], [90, 180], true))
                {
                    $p--;
                } else
                {
                    $p += 2;
                }
            }
            if (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase6]))
            {
                if (in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase6]['phase_e'], [90, 180], true))
                {
                    $p -= 2;
                } else
                {
                    $p++;
                }
            }
            if ((isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase7])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase7]['phase_e'], [90, 180], true))
                ||
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase8])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase8]['phase_e'], [90, 180], true))
                ||
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase9])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase9]['phase_e'], [90, 180], true))
            )
            {
                $p -= 3;
            }
            //C、当2R 主接纳互容火、土
            if ($house2ProtectAncientRemrMars)
            {
                //a、火、土为 2/4/5/8/10/11宫主或位于这些宫位，且尊贵禀赋得分大于等于 3 分，+2 分（只计火土各一次）
                if ($marsAncientPower >= 3
                    && (in_array($firdaria['planets'][4]['in_house_id'], [2, 4, 5, 8, 10, 11], true)
                        || $firdaria['houses'][2]['protect_ancient_id'] === 4
                        || $firdaria['houses'][4]['protect_ancient_id'] === 4
                        || $firdaria['houses'][5]['protect_ancient_id'] === 4
                        || $firdaria['houses'][8]['protect_ancient_id'] === 4
                        || $firdaria['houses'][10]['protect_ancient_id'] === 4
                        || $firdaria['houses'][11]['protect_ancient_id'] === 4))
                {
                    $p += 2;
                }//b、火、土为8/12宫主或位于这些宫位，且尊贵禀赋得分小0分，-3 分（只计火土各一次）
                elseif ($marsAncientPower < 0
                    && (in_array($firdaria['planets'][4]['in_house_id'], [8, 12], true)
                        || $firdaria['houses'][8]['protect_ancient_id'] === 4
                        || $firdaria['houses'][12]['protect_ancient_id'] === 4))
                {
                    $p -= 3;
                }
            }
            if ($house2ProtectAncientRemrSatu)
            {
                //a、火、土为 2/4/5/8/10/11宫主或位于这些宫位，且尊贵禀赋得分大于等于 3 分，+2 分（只计火土各一次）
                if ($satuAncientPower >= 3
                    && (in_array($firdaria['planets'][6]['in_house_id'], [2, 4, 5, 8, 10, 11], true)
                        || $firdaria['houses'][2]['protect_ancient_id'] === 6
                        || $firdaria['houses'][4]['protect_ancient_id'] === 6
                        || $firdaria['houses'][5]['protect_ancient_id'] === 6
                        || $firdaria['houses'][8]['protect_ancient_id'] === 6
                        || $firdaria['houses'][10]['protect_ancient_id'] === 6
                        || $firdaria['houses'][11]['protect_ancient_id'] === 6))
                {
                    $p += 2;
                }//b、火、土为8/12宫主或位于这些宫位，且尊贵禀赋得分小0分，-3 分（只计火土各一次）
                elseif ($satuAncientPower < 0
                    && (in_array($firdaria['planets'][6]['in_house_id'], [8, 12], true)
                        || $firdaria['houses'][8]['protect_ancient_id'] === 6
                        || $firdaria['houses'][12]['protect_ancient_id'] === 6))
                {
                    $p -= 3;
                }
            }
        }
        //⑧ 若该主限运行星接纳/互容 2R 主，+1 分
        //⑧若该主限运行星接纳/互容 2R 主，+3 分  20191218 edit by seunk
        if ($pidRemrHouse2ProtectAncient)
        {
            $p += 3;
        }
        //⑨若该主限运行星与日、金、木有 0/60/120相位，+1 分（只计金木各一次）
        // +3 20191217 edit by seunk
        $pidPhase0 = $pid . '-0';
        $pidPhase3 = $pid . '-3';
        $pidPhase5 = $pid . '-5';
        if (isset($firdaria['planets'][$pid]['phase'][$pidPhase3])
            && in_array($firdaria['planets'][$pid]['phase'][$pidPhase3]['phase_e'], [0, 60, 120], true))
        {
            $p += 3;
        }
        if (isset($firdaria['planets'][$pid]['phase'][$pidPhase5])
            && in_array($firdaria['planets'][$pid]['phase'][$pidPhase5]['phase_e'], [0, 60, 120], true))
        {
            $p += 3;
        }
        if (isset($firdaria['planets'][$pid]['phase'][$pidPhase0])
            && in_array($firdaria['planets'][$pid]['phase'][$pidPhase0]['phase_e'], [0, 60, 120], true))
        {
            $p += 3;
        }
        //⑩若该主限运行星与火土天海冥刑克，-3 分（只计一次）
        $pidPhase4 = $pid . '-4';
        $pidPhase6 = $pid . '-6';
        $pidPhase7 = $pid . '-7';
        $pidPhase8 = $pid . '-8';
        $pidPhase9 = $pid . '-9';
        if ((isset($firdaria['planets'][$pid]['phase'][$pidPhase4])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase4]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase6])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase6]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase7])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase7]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase8])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase8]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase9])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase9]['phase_e'], [0, 60, 120], true)))
        {
            $p -= 3;
        }
        //⑫若该主限运行星是5R 主，+1分
        if ($pid === $firdaria['houses'][5]['protect_ancient_id'])
        {
            $p++;
        }
        // 若该主限运行星是4R 主，+1分 20191219 edit by seunk
        if ($pid === $firdaria['houses'][4]['protect_ancient_id'])
        {
            $p++;
        }
        //⑬若该主限运行星是8R 主，+1分
        if ($pid === $firdaria['houses'][8]['protect_ancient_id'])
        {
            $p++;
        }
        //⑭若该主限运行星是11R 主，+2分
        if ($pid === $firdaria['houses'][11]['protect_ancient_id'])
        {
            $p += 2;
        }
        // ['characteristic'][11] 夹星为11
        if (!empty($receptOrMutualRecept[11]))
        {
            foreach ($receptOrMutualRecept[11] as $k => $v)
            {
                if ($v['planet_id'] === $pid)
                {
                    //⑮若该主限运行星被金木夹、日木、月木、日金夹，+3 分 20191218 edit by seunk
                    if (in_array($v['id1'], [3, 5], true) && in_array($v['id2'], [3, 5], true))
                    {
                        $p += 3;
                    }
                    if (in_array($v['id1'], [0, 5], true) && in_array($v['id2'], [0, 5], true))
                    {
                        $p += 3;
                    }
                    if (in_array($v['id1'], [1, 5], true) && in_array($v['id2'], [1, 5], true))
                    {
                        $p += 3;
                    }
                    if (in_array($v['id1'], [0, 3], true) && in_array($v['id2'], [0, 3], true))
                    {
                        $p += 3;
                    }
                    //若该主限运行星被日月夹，+1 分 20191218 edit by seunk
                    if (in_array($v['id1'], [0, 1], true) && in_array($v['id2'], [0, 1], true))
                    {
                        $p++;
                    }
                    //若该主限运行星被火土夹，-3 分 20191218 edit by seunk
                    if (in_array($v['id1'], [4, 6], true) && in_array($v['id2'], [4, 6], true))
                    {
                        $p -= 3;
                    }
                }
            }
        }
        // ['characteristic'][13] 夹辅为13
        if (!empty($receptOrMutualRecept[13]))
        {
            foreach ($receptOrMutualRecept[13] as $k => $v)
            {
                if ($v['planet_id'] === $pid)
                {
                    //⑯若该主限运行星被金木夹、日木、月木、日金夹，+2 分 20191219 edit by seunk
//                    if (in_array($v['id1'], [3, 5], true) && in_array($v['id2'], [3, 5], true))
//                    {
//                        $p += 2;
//                    }
//                    if (in_array($v['id1'], [0, 5], true) && in_array($v['id2'], [0, 5], true))
//                    {
//                        $p += 2;
//                    }
                    if (in_array($v['id1'], [1, 5], true) && in_array($v['id2'], [1, 5], true))
                    {
                        $p += 2;
                    }
//                    if (in_array($v['id1'], [0, 3], true) && in_array($v['id2'], [0, 3], true))
//                    {
//                        $p += 2;
//                    }
//                    //若该主限运行星被日月夹，+1 分 20191219 edit by seunk
//                    if (in_array($v['id1'], [0, 1], true) && in_array($v['id2'], [0, 1], true))
//                    {
//                        $p++;
//                    }
                }
            }
        }

        // 若该主限运行星与土星
        return $p;
    }

    /**
     * 获取财富报告曲线图 p1 p2分数
     * @param null $pid 大运 || 小运 行星id
     * @param array $firdaria 法达盘数据
     * @param array $receptOrMutualRecept 本命行星互容接纳数据
     * @return int
     */
    private function getMainOrSubScoreOld($pid = null, $firdaria = [], $receptOrMutualRecept = [])
    {
        $house2ProtectAncient = $firdaria['houses'][2]['protect_ancient_id'];
        $pidIsVenuOrJupi = in_array($pid, [3, 5], true);
        $pidIsMarsOrSatu = in_array($pid, [4, 6], true);
        // 金星的尊贵禀赋
        $venuAncientPower = $firdaria['planets'][3]['ancient']['power'];
        if ($firdaria['planets'][3]['ancient']['migration'])
        {
            $venuAncientPower += 5;
        }
        // 火星的尊贵禀赋
        $marsAncientPower = $firdaria['planets'][4]['ancient']['power'];
        if ($firdaria['planets'][4]['ancient']['migration'])
        {
            $marsAncientPower += 5;
        }
        // 木星的尊贵禀赋
        $jupiAncientPower = $firdaria['planets'][5]['ancient']['power'];
        if ($firdaria['planets'][5]['ancient']['migration'])
        {
            $jupiAncientPower += 5;
        }
        // 土星的尊贵禀赋
        $satuAncientPower = $firdaria['planets'][6]['ancient']['power'];
        if ($firdaria['planets'][6]['ancient']['migration'])
        {
            $satuAncientPower += 5;
        }
        //【P计分方式】
        //①日、金、水、月、土、木、火尊贵禀赋得分（+5、+4、+3、+2、+1、-5、-4），游走计 0 分
        // 南交双子-4 南交射手+4 北交双子+4 北交射手-4 其它为 0
        $p = $firdaria['planets'][$pid]['ancient']['power'];
        switch ($pid)
        {
            // 北交点
            case 12:
                if ($firdaria['planets'][$pid]['in_sign_id'] === 3)
                {
                    $p = 4;
                } elseif ($firdaria['planets'][$pid]['in_sign_id'] === 9)
                {
                    $p = -4;
                }
                break;
            // 南交点
            case 16:
                if ($firdaria['planets'][$pid]['in_sign_id'] === 3)
                {
                    $p = -4;
                } elseif ($firdaria['planets'][$pid]['in_sign_id'] === 9)
                {
                    $p = 4;
                }
                break;
            default:
                // 游走记0分
                if ($firdaria['planets'][$pid]['ancient']['migration'])
                {
                    $p = 0;
                }
                break;
        }
        //②若该主限行星为金、木，+1 分
        if ($pidIsVenuOrJupi)
        {
            $p++;
        } //③若该主限行星为火、土，-1 分
        elseif ($pidIsMarsOrSatu)
        {
            $p--;
        }
        //⑤若该主限运行星落 2 宫内，金木+1、日月水+0、火土-1
        if ($firdaria['planets'][$pid]['in_house_id'] === 2)
        {
            if ($pidIsVenuOrJupi)
            {
                $p++;
            } elseif ($pidIsMarsOrSatu)
            {
                $p--;
            }
        }
        //⑥若该主限运行星接纳/互容金木（接纳指产生接纳关系即可，不区分主动被动）
        $pidRemrVenu = false;
        $pidRemrJupi = false;
        $house2ProtectAncientRemrVenu = false;
        $house2ProtectAncientRemrMars = false;
        $house2ProtectAncientRemrJupi = false;
        $house2ProtectAncientRemrSatu = false;
        $pidRemrHouse2ProtectAncient = false;
        if (!empty($receptOrMutualRecept))
        {
            foreach ($receptOrMutualRecept as $r => $remr)
            {
                if ($r <= 2 && !empty($remr))
                {
                    foreach ($remr as $rm)
                    {
                        // 行星与金星产生接纳or互容关系
                        if (!$pidRemrVenu && (($rm['id1'] === 3 && $pid === $rm['id2'])
                                || ($rm['id2'] === 3 && $pid === $rm['id1'])))
                        {
                            $pidRemrVenu = true;
                            //a、金、木尊贵禀赋得分大于等于3分，+3 分
                            if ($venuAncientPower >= 3)
                            {
                                $p += 3;
                            }//b、金、木尊贵禀赋得分大于等于 0 分，+1 分
                            elseif ($venuAncientPower >= 0)
                            {
                                $p++;
                            }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                            else
                            {
                                $p--;
                            }
                        }
                        // 行星与木星产生接纳or互容关系
                        if (!$pidRemrJupi && (($rm['id1'] === 5 && $pid === $rm['id2'])
                                || ($rm['id2'] === 5 && $pid === $rm['id1'])))
                        {
                            $pidRemrJupi = true;
                            //a、金、木尊贵禀赋得分大于等于3分，+3 分
                            if ($jupiAncientPower >= 3)
                            {
                                $p += 3;
                            }//b、金、木尊贵禀赋得分大于等于 0 分，+1 分
                            elseif ($jupiAncientPower >= 0)
                            {
                                $p++;
                            }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                            else
                            {
                                $p--;
                            }
                        }
                        // 2宫主与金星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrVenu && (($rm['id1'] === 3 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 3 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrVenu = true;
                        }
                        // 2宫主与火星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrMars && (($rm['id1'] === 4 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 4 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrMars = true;
                        }
                        // 2宫主与木星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrJupi && (($rm['id1'] === 5 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 5 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrJupi = true;
                        }
                        // 2宫主与土星产生接纳or互容关系
                        if (!$house2ProtectAncientRemrSatu && (($rm['id1'] === 6 && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === 6 && $house2ProtectAncient === $rm['id1'])))
                        {
                            $house2ProtectAncientRemrSatu = true;
                        }
                        // 行星与2宫主产生接纳or互容关系
                        if (!$pidRemrHouse2ProtectAncient && (($rm['id1'] === $pid && $house2ProtectAncient === $rm['id2'])
                                || ($rm['id2'] === $pid && $house2ProtectAncient === $rm['id1'])))
                        {
                            $pidRemrHouse2ProtectAncient = true;
                        }
                    }
                }
            }
        }
        //⑦若该主限运行星是2R 主，
        if ($pid === $house2ProtectAncient)
        {
            //④若该主限运行星是2R 主，+2分 // 20191205 +5分
            $p += 5;
            //A、当2R 主接纳/互容金、木 （只计金木各一次）
            if ($house2ProtectAncientRemrVenu)
            {
                //a、金、木尊贵禀赋得分大于等于3分，+4 分
                // +5 20191217 edit by seunk
                if ($venuAncientPower >= 3)
                {
                    $p += 5;
                }//b、金、木尊贵禀赋得分大于等于 0 分，+2 分
                // +3 20191217 edit by seunk
                elseif ($venuAncientPower >= 0)
                {
                    $p += 3;
                }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                else
                {
                    $p--;
                }
            }
            if ($house2ProtectAncientRemrJupi)
            {
                //a、金、木尊贵禀赋得分大于等于3分，+4 分
                // +5 20191217 edit by seunk
                if ($jupiAncientPower >= 3)
                {
                    $p += 5;
                }//b、金、木尊贵禀赋得分大于等于 0 分，+2 分
                // +3 20191217 edit by seunk
                elseif ($jupiAncientPower >= 0)
                {
                    $p += 3;
                }//c、金、木尊贵禀赋得分小于 0 分，-1 分
                else
                {
                    $p--;
                }
            }
            //B、当2R 主被火土天海冥刑克，-3 分 （只计一次）
            $house2ProtectAncientPhase4 = $house2ProtectAncient . '-' . 4;
            $house2ProtectAncientPhase6 = $house2ProtectAncient . '-' . 6;
            $house2ProtectAncientPhase7 = $house2ProtectAncient . '-' . 7;
            $house2ProtectAncientPhase8 = $house2ProtectAncient . '-' . 8;
            $house2ProtectAncientPhase9 = $house2ProtectAncient . '-' . 9;
            if (
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase4])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase4]['phase_e'], [90, 180], true))
                ||
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase6])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase6]['phase_e'], [90, 180], true))
                ||
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase7])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase7]['phase_e'], [90, 180], true))
                ||
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase8])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase8]['phase_e'], [90, 180], true))
                ||
                (isset($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase9])
                    && in_array($firdaria['planets'][$house2ProtectAncient]['phase'][$house2ProtectAncientPhase9]['phase_e'], [90, 180], true))
            )
            {
                $p -= 3;
            }
            //C、当2R 主接纳互容火、土
            if ($house2ProtectAncientRemrMars)
            {
                //a、火、土为 2/4/5/8/10/11宫主或位于这些宫位，且尊贵禀赋得分大于等于 3 分，+2 分（只计火土各一次）
                if ($marsAncientPower >= 3
                    && (in_array($firdaria['planets'][4]['in_house_id'], [2, 4, 5, 8, 10, 11], true)
                        || $firdaria['houses'][2]['protect_ancient_id'] === 4
                        || $firdaria['houses'][4]['protect_ancient_id'] === 4
                        || $firdaria['houses'][5]['protect_ancient_id'] === 4
                        || $firdaria['houses'][8]['protect_ancient_id'] === 4
                        || $firdaria['houses'][10]['protect_ancient_id'] === 4
                        || $firdaria['houses'][11]['protect_ancient_id'] === 4))
                {
                    $p += 2;
                }//b、火、土为8/12宫主或位于这些宫位，且尊贵禀赋得分小0分，-3 分（只计火土各一次）
                elseif ($marsAncientPower < 0
                    && (in_array($firdaria['planets'][4]['in_house_id'], [8, 12], true)
                        || $firdaria['houses'][8]['protect_ancient_id'] === 4
                        || $firdaria['houses'][12]['protect_ancient_id'] === 4))
                {
                    $p -= 3;
                }
            }
            if ($house2ProtectAncientRemrSatu)
            {
                //a、火、土为 2/4/5/8/10/11宫主或位于这些宫位，且尊贵禀赋得分大于等于 3 分，+2 分（只计火土各一次）
                if ($satuAncientPower >= 3
                    && (in_array($firdaria['planets'][6]['in_house_id'], [2, 4, 5, 8, 10, 11], true)
                        || $firdaria['houses'][2]['protect_ancient_id'] === 6
                        || $firdaria['houses'][4]['protect_ancient_id'] === 6
                        || $firdaria['houses'][5]['protect_ancient_id'] === 6
                        || $firdaria['houses'][8]['protect_ancient_id'] === 6
                        || $firdaria['houses'][10]['protect_ancient_id'] === 6
                        || $firdaria['houses'][11]['protect_ancient_id'] === 6))
                {
                    $p += 2;
                }//b、火、土为8/12宫主或位于这些宫位，且尊贵禀赋得分小0分，-3 分（只计火土各一次）
                elseif ($satuAncientPower < 0
                    && (in_array($firdaria['planets'][6]['in_house_id'], [8, 12], true)
                        || $firdaria['houses'][8]['protect_ancient_id'] === 6
                        || $firdaria['houses'][12]['protect_ancient_id'] === 6))
                {
                    $p -= 3;
                }
            }
        }
        //⑧ 若该主限运行星接纳/互容 2R 主，+1 分
        if ($pidRemrHouse2ProtectAncient)
        {
            $p++;
        }
        //⑨若该主限运行星与金、木有 0/60/120相位，+1 分（只计金木各一次）
        // +3 20191217 edit by seunk
        $pidPhase3 = $pid . '-3';
        $pidPhase5 = $pid . '-5';
        if (isset($firdaria['planets'][$pid]['phase'][$pidPhase3])
            && in_array($firdaria['planets'][$pid]['phase'][$pidPhase3]['phase_e'], [0, 60, 120], true))
        {
            $p += 3;
        }
        if (isset($firdaria['planets'][$pid]['phase'][$pidPhase5])
            && in_array($firdaria['planets'][$pid]['phase'][$pidPhase5]['phase_e'], [0, 60, 120], true))
        {
            $p += 3;
        }
        //⑩若该主限运行星与火土天海冥刑克，-3 分（只计一次）
        $pidPhase4 = $pid . '-4';
        $pidPhase6 = $pid . '-6';
        $pidPhase7 = $pid . '-7';
        $pidPhase8 = $pid . '-8';
        $pidPhase9 = $pid . '-9';
        if ((isset($firdaria['planets'][$pid]['phase'][$pidPhase4])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase4]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase6])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase6]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase7])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase7]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase8])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase8]['phase_e'], [0, 60, 120], true))
            || (isset($firdaria['planets'][$pid]['phase'][$pidPhase9])
                && in_array($firdaria['planets'][$pid]['phase'][$pidPhase9]['phase_e'], [0, 60, 120], true)))
        {
            $p -= 3;
        }
        //⑪若该主限运行星为南北交
        if ($pid === 12 || $pid === 16)
        {
            //A、看与之会合行星是否满足以上 10 个条件
            if (!empty($firdaria['planets'][$pid]['phase']))
            {
                foreach ($firdaria['planets'][$pid]['phase'] as $phase)
                {
                    if ($phase['phase_e'] === 0 && $phase['id'] < 7)
                    {
                        $p += $this->getMainOrSubScore($phase['id'], $firdaria, $receptOrMutualRecept);
                    }
                }
            }
            //B、看其定位行星是否满足以上 10 个条件
            $nPid = $firdaria['houses'][$firdaria['planets'][$pid]['in_house_id']]['protect_ancient_id'];
            $p += $this->getMainOrSubScore($nPid, $firdaria, $receptOrMutualRecept);
        }
        //⑫若该主限运行星是5R 主，+1分
        if ($pid === $firdaria['houses'][5]['protect_ancient_id'])
        {
            $p++;
        }
        //⑬若该主限运行星是8R 主，+1分
        if ($pid === $firdaria['houses'][8]['protect_ancient_id'])
        {
            $p++;
        }
        //⑭若该主限运行星是11R 主，+2分
        if ($pid === $firdaria['houses'][11]['protect_ancient_id'])
        {
            $p += 2;
        }

        return $p;
    }

    /**
     * 财富主题 1：财富观念综述
     * @return array
     */
    protected function getMoneySection1(): array
    {
        $houses = $this->astroData['houses'];
        // 2宫宫头星座    2宫宫主星
        $house2InSign = (int)$houses[2]['in_sign_id'];

        $conf = [
            'house' => 2,
            'list' => [
                ['id' => 1, 's' => [3, 1, 5, 2]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [1]],
                ['id' => 4, 's' => [2]]
            ],
        ];
        // 影响星级：
        $levels[] = $this->getMoneySectionInfluence($conf);

        $tags = [
            // 金钱层面获得观念
            10000000 + $house2InSign - 1,
            // 金钱层面消费观念
            10000100 + (int)$houses[2]['protect_id'],
        ];

        $result = [
            'desc' => '主题 1：个人金钱财富观念综述',
            'content_list' => $tags,
            'levels' => $levels
        ];

        return $result;
    }

    /**
     * 财富主题 2：财富来源及方式
     * @return array
     */
    protected function getMoneySection2(): array
    {
        $tags = $levels = [];
        // 顺序为 宫主星、宫主飞宫、古典宫主星力量强弱、古典宫主星与其他古典宫主星的吉凶相位
        $this->getHouseProtectInHouseAncientPowerPhaseTypes(2, $tags, 0);
        $this->getHouseProtectInHouseAncientPowerPhaseTypes(11, $tags, 1);
        $this->getHouseProtectInHouseAncientPowerPhaseTypes(4, $tags, 2);
        $this->getHouseProtectInHouseAncientPowerPhaseTypes(8, $tags, 3);
        $this->getHouseProtectInHouseAncientPowerPhaseTypes(5, $tags, 4);
        $this->getHouseProtectInHouseAncientPowerPhaseTypes(8, $tags, 5);
        //0 = {int} 100100010309
        //1 = {int} 1001000004020101
        //2 = {int} 100100020009
        //3 = {int} 100100021002
        //4 = {int} 10010000020905
        //5 = {int} 1001000005040000
        //6 = {int} 1001000005040100
        //7 = {int} 100100030008
        //8 = {int} 100100030904
        //9 = {int} 10010000020806
        //10 = {int} 1001000006050101
        //11 = {int} 100100040005
        //12 = {int} 100100040609
        //13 = {int} 1001000007050101
        //14 = {int} 100100050008
        //15 = {int} 100100050904
        //16 = {int} 10010000020806
        //17 = {int} 1001000008050101
        // 打工薪酬收入的情况 影响星级：
        $conf1 = [
            'house' => 2,
            'house2' => 6,
            'list' => [
                ['id' => 1, 's' => [1, 3, 5, 2]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [1]],
                ['id' => 4, 's' => [2]],
                ['id' => 5, 's' => [-1]],
                ['id' => 6, 's' => [-2]],
                ['id' => 7, 's' => [1]],
                ['id' => 8, 's' => [3]],
                ['id' => 9, 's' => [1]],
                ['id' => 10, 's' => [1]]
            ],
        ];
        $levels[] = $this->getMoneySectionInfluence($conf1);
        // 事业经营收入的情况 影响星级：
        $conf2 = [
            'house' => 11,
            'house2' => 2,
            'list' => [
                ['id' => 1, 's' => [2, 3, 1, 5]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [2]],
                ['id' => 4, 's' => [2]],
                ['id' => 5, 's' => [-2]],
                ['id' => 6, 's' => [-1]],
                ['id' => 7, 's' => [-3]],
                ['id' => 8, 's' => [3]],
                ['id' => 9, 's' => [1]],
                ['id' => 10, 's' => [2]]
            ],
        ];
        $levels[] = $this->getMoneySectionInfluence($conf2);
        // 不动产继承情况 影响星级：
        $conf3 = [
            'house' => 4,
            'house2' => 2,
            'list' => [
                ['id' => 1, 's' => [5, 2, 3, 1]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [2]],
                ['id' => 4, 's' => [2]],
                ['id' => 5, 's' => [-2]],
                ['id' => 6, 's' => [-1]],
                ['id' => 7, 's' => [-3]],
                ['id' => 8, 's' => [3]],
                ['id' => 9, 's' => [1]],
                ['id' => 10, 's' => [2]]
            ],
        ];
        $levels[] = $this->getMoneySectionInfluence($conf3);
        // 动产继承情况 影响星级：
        $conf4 = [
            'house' => 8,
            'house2' => 2,
            'list' => [
                ['id' => 1, 's' => [5, 1, 3, 2]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [2]],
                ['id' => 4, 's' => [2]],
                ['id' => 5, 's' => [-1]],
                ['id' => 6, 's' => [-2]],
                ['id' => 7, 's' => [-3]],
                ['id' => 8, 's' => [3]],
                ['id' => 9, 's' => [1]],
                ['id' => 10, 's' => [2]]
            ],
        ];
        $levels[] = $this->getMoneySectionInfluence($conf4);
        // 投机收入的情况 影响星级：
        $conf5 = [
            'house' => 5,
            'house2' => 2,
            'list' => [
                ['id' => 1, 's' => [2, 5, 1, 3]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [2]],
                ['id' => 4, 's' => [2]],
                ['id' => 5, 's' => [-1]],
                ['id' => 6, 's' => [-2]],
                ['id' => 7, 's' => [-3]],
                ['id' => 8, 's' => [3]],
                ['id' => 9, 's' => [1]],
                ['id' => 10, 's' => [2]]
            ],
        ];
        $levels[] = $this->getMoneySectionInfluence($conf5);
        // 投资收入的情况 影响星级：
        $conf6 = [
            'house' => 8,
            'house2' => 2,
            'list' => [
                ['id' => 1, 's' => [2, 5, 1, 3]],
                ['id' => 2, 's' => []],
                ['id' => 3, 's' => [2]],
                ['id' => 4, 's' => [2]],
                ['id' => 5, 's' => [-1]],
                ['id' => 6, 's' => [-2]],
                ['id' => 7, 's' => [-3]],
                ['id' => 8, 's' => [3]],
                ['id' => 9, 's' => [1]],
                ['id' => 10, 's' => [2]]
            ],
        ];
        $levels[] = $this->getMoneySectionInfluence($conf6);

        $result = [
            'desc' => '主题 2：个人财富来源及方式',
            'content_list' => $tags,
            'levels' => $levels,
        ];
        return $result;
    }

    /**
     * 获取影响星级 分值为int
     * @param array $config
     * @return int
     */
    private function getMoneySectionInfluence($config = []): int
    {
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        // 用本命盘计算行星互容接纳数据
        $receptOrMutualRecept = Astrolog::getInstance()->receptOrMutualRecept($planets);
        $s = 0;
        // 古典宫主星
        $houseProtectAncient = $houses[$config['house']]['protect_ancient_id'];
        foreach ($config['list'] as $i => $conf)
        {
            switch ($conf['id'])
            {
                case 1:
                    // ①选择A宫头落的星座，判断星座四元素，土象+5 分，水象+3 分、风象+2 分、火象+1 分
                    switch ($houses[$config['house']]['in_sign_id'] % 4)
                    {
                        case 1:
                            $s += $conf['s'][1];
                            break;
                        case 2:
                            $s += $conf['s'][2];
                            break;
                        case 3:
                            $s += $conf['s'][3];
                            break;
                        default:
                            $s += $conf['s'][0];
                            break;
                    }
                    break;
                case 2:
                    // ②选择A宫古典宫主星，根据宫主星落点的尊贵禀赋（+5、+4、+3、+2、+1、-5、-4），游走计 0 分
                    // 尊贵禀赋规则（只调用 1 个）：庙＞旺＞三分＞界＞十度＞陷＞弱＞游走 20191214
                    if ($planets[$houseProtectAncient]['ancient']['walls'] === 1)
                    {
                        $s += 5;
                    } elseif ($planets[$houseProtectAncient]['ancient']['promote'] === 1)
                    {
                        $s += 4;
                    } elseif ($planets[$houseProtectAncient]['ancient']['trisection'] === 1)
                    {
                        $s += 3;
                    } elseif ($planets[$houseProtectAncient]['ancient']['extent'] === 1)
                    {
                        $s += 2;
                    } elseif ($planets[$houseProtectAncient]['ancient']['period'] === 1)
                    {
                        $s++;
                    } elseif ($planets[$houseProtectAncient]['ancient']['walls'] === 2)
                    {
                        $s -= 5;
                    } elseif ($planets[$houseProtectAncient]['ancient']['promote'] === 2)
                    {
                        $s -= 4;
                    }
                    break;
                case 3:
                    // ③2宫主若为日月金木，+1
                    if (in_array($houseProtectAncient, [0, 1, 3, 5], true))
                    {
                        $s += $conf['s'][0];
                    }
                    break;
                case 4:
                    // ④2宫内若有日月金木，+2
                    if ($planets[0]['in_house_id'] === $config['house'] || $planets[1]['in_house_id'] === $config['house'] || $planets[3]['in_house_id'] === $config['house'] || $planets[5]['in_house_id'] === $config['house'])
                    {
                        $s += $conf['s'][0];
                    }
                    break;
                case 5:
                    //⑤2 宫主若为火土，-1
                    if (in_array($houseProtectAncient, [4, 6], true))
                    {
                        $s += $conf['s'][0];
                    }
                    break;
                case 6:
                    //⑥2 宫内若有天海，-2
                    if ($planets[7]['in_house_id'] === $config['house'] || $planets[8]['in_house_id'] === $config['house'])
                    {
                        $s += $conf['s'][0];
                    }
                    break;
                case 7:
                    //⑦2 宫内若有冥王，+1
                    if ($planets[9]['in_house_id'] === $config['house'])
                    {
                        $s += $conf['s'][0];
                    }
                    break;
                case 8:
                    // ⑧2 宫主接纳/互容金木，+3 分
                    if (!empty($receptOrMutualRecept))
                    {
                        foreach ($receptOrMutualRecept as $key => $remr)
                        {
                            if ($key <= 2)
                            {
                                foreach ($remr as $rm)
                                {
                                    if (($rm['id1'] === $houseProtectAncient && in_array($rm['id2'], [3, 5], true))
                                        || ($rm['id2'] === $houseProtectAncient && in_array($rm['id1'], [3, 5], true)))
                                    {
                                        $s += $conf['s'][0];
                                        break 2;
                                    }
                                }
                            }
                        }
                    }
                    break;
                case 9:
                    //⑨2 宫主0/60/120°金木，+1 分
                    $houseProtectAncientPhaseVenu = $houseProtectAncient . '-3';
                    $houseProtectAncientPhaseJupi = $houseProtectAncient . '-5';
                    if ((isset($planets[$houseProtectAncient]['phase'][$houseProtectAncientPhaseVenu])
                            && in_array($planets[$houseProtectAncient]['phase'][$houseProtectAncientPhaseVenu]['phase_e'], [0, 60, 120], true))
                        || (isset($planets[$houseProtectAncient]['phase'][$houseProtectAncientPhaseJupi])
                            && in_array($planets[$houseProtectAncient]['phase'][$houseProtectAncientPhaseJupi]['phase_e'], [0, 60, 120], true))
                    )
                    {
                        $s += $conf['s'][0];
                    }
                    break;
                case 10:
                    // ⑩A宫主接纳互容B宫主，+s 分
                    $house2ProtectAncient = $houses[$config['house2']]['protect_ancient_id'];
                    if (!empty($receptOrMutualRecept))
                    {
                        foreach ($receptOrMutualRecept as $key => $remr)
                        {
                            if ($key <= 2)
                            {
                                foreach ($remr as $rm)
                                {
                                    if (($rm['id1'] === $houseProtectAncient && $rm['id2'] === $house2ProtectAncient)
                                        || ($rm['id2'] === $houseProtectAncient && $rm['id1'] === $house2ProtectAncient))
                                    {
                                        $s += $conf['s'][0];
                                        break 2;
                                    }
                                }
                            }
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        //星级规则：
        //0≤ 1 星
        //3≤ 2 星
        //5≤ 3 星
        //8≤ 4 星
        //8＞ 5 星
        //星级禀赋计分：以尊贵禀赋加减总和计算
        if ($s > 8)
        {
            $lv = 5;
        } elseif ($s > 6)
        {
            $lv = 4;
        } elseif ($s > 4)
        {
            $lv = 3;
        } elseif ($s > 1)
        {
            $lv = 2;
        } else
        {
            $lv = 1;
        }
        return $lv;
    }

    /**
     * 主题 3：财富层次分析
     * @return array
     */
    protected function getMoneySection3(): array
    {
        $planets = $this->astroData['planets'];
        // 取得福点相关数据
        $fortune = $planets[14];
        // 在你的一生之中，经过漫长的人生岁月历练之后，你的财富整体会以【这样的形式积累】：（福点的落座：白羊、金牛、双子、巨蟹、狮子、处女、天秤、天蝎、射手、摩羯、水瓶、双鱼）
        $fortuneInSign = $fortune['in_sign_id'];
        // 你的财富情况会是这样【等级判断】：（福点定位星落宫 （福点盘宫位）：1、4、7、10、11；2、5、8、9；3、6、12）
        // 计算福点盘12宫宫头度数
        $houseStart = floor($fortune['deg'] / 30) * 30;
        $houses = [];
        for ($i = 1; $i < 13; $i++)
        {
            $deg = $houseStart + ($i - 1) * 30;
            $deg = $deg - floor($deg / 360) * 360;
            $houses[$i] = $deg;
        }
        // 获取福点定位星(福点落座古典守护星)
        $protectAncientId = [4, 3, 2, 1, 0, 2, 3, 4, 5, 6, 6, 5];
        $fortDispositor = $protectAncientId[$fortune['in_sign_id'] - 1];
        // 判断福点定位星落宫
        $fortDispositorInHouse = InWhichHouse($planets[$fortDispositor]['deg'], $houses);

        $tags = [
            // 福点的落座
            10020000 + $fortuneInSign - 1,
            // 福点古典定位星落宫
            10020100 + $fortDispositorInHouse - 1,
        ];
        // 财富【是否会持续或变化】：福点定位星落座的3 个三分行星，与其他星的吉相位(60/120°)、凶相位（90/180°）、半吉半凶（0°）、空相
        // 福点定位星落座三分主星
        $fortDispositorTrisection = $planets[$fortDispositor]['ancient']['or_trisection_planet_id'];
        $phaseIds = [];
        foreach ($fortDispositorTrisection as $fdp)
        {
            $phaseNum = 0;
            $phases = [];
            if (!empty($planets[$fdp]['phase']))
            {
                foreach ($planets[$fdp]['phase'] as $phase)
                {
                    if ($phase['id'] < 10 && in_array($phase['phase_e'], [0, 60, 90, 120, 180]))
                    {
                        $phases[] = [
                            'phase_id' => $phase['id'],
                            'phase_orb' => $phase['phase_orb'],
                            'code' => 1002020000 + $phase['id'] * 100 + $this->getPhaseType($phase['phase_e']),
                        ];
                        $phaseNum++;
                    }
                }
            }
            // 仅调用最紧密的相位
            if ($phaseNum > 0)
            {
                $phases = resort($phases, 'phase_orb', 'ASC');
                if (!in_array($phases[0]['phase_id'], $phaseIds))
                {
                    $phaseIds[] = $phases[0]['phase_id'];
                    // 调用最紧密相位
                    $tags[] = $phases[0]['code'];
                } elseif ($phaseNum > 1 && !in_array($phases[0]['phase_id'], $phaseIds))
                {
                    $phaseIds[] = $phases[1]['phase_id'];
                    // 调用次要紧密相位
                    $tags[] = $phases[1]['code'];
                } elseif ($phaseNum > 2 && !in_array($phases[2]['phase_id'], $phaseIds))
                {
                    $phaseIds[] = $phases[2]['phase_id'];
                    // 继续调用次要紧密相位，避免重复
                    $tags[] = $phases[2]['code'];
                } else
                {
                    // 否则调用空相词条
                    $tags[] = 10020210 + $fdp;
                }
            } // 空相
            elseif ($phaseNum === 0)
            {
                $tags[] = 10020210 + $fdp;
            }
        }


        $l = 0;
        // 影响星级：
        //①选择福点落的星座，
        // 金牛/双鱼+5 分，
        if (in_array($fortuneInSign, [2, 12], true))
        {
            $l += 5;
        }// 天秤/射手/巨蟹/狮子+4 分、
        elseif (in_array($fortuneInSign, [4, 5, 7, 9], true))
        {
            $l += 4;
        }// 天蝎、摩羯、水瓶，-5分；
        elseif (in_array($fortuneInSign, [8, 10, 11], true))
        {
            $l -= 5;
        }// 双子+3 分、
        elseif ($fortuneInSign === 3)
        {
            $l += 3;
        }// 处女+2分；
        elseif ($fortuneInSign === 6)
        {
            $l += 2;
        }// 白羊，+0 分
//        elseif($fortuneInSign === 1)
//        {
//            $l += 0;
//        }
        //②福点定位星落福点起始的
        //1/4/7/10宫,+5分；
        if (in_array($fortDispositorInHouse, [1, 4, 7, 10], true))
        {
            $l += 5;
        }//2/5/11宫，+3；
        elseif (in_array($fortDispositorInHouse, [2, 5, 11], true))
        {
            $l += 3;
        }//3/9宫+1；
        elseif (in_array($fortDispositorInHouse, [3, 9], true))
        {
            $l++;
        }//6/8/宫，-2分;
        if (in_array($fortDispositorInHouse, [6, 8], true))
        {
            $l -= 2;
        }//12 宫，-5 分
        else
        {
            $l -= 5;
        }
        //③福点定位星为日月金木，+2分
        if (in_array($fortDispositor, [0, 1, 3, 5], true))
        {
            $l += 2;
        }
        //④福点定位星与火土天海冥90/180°，-2 分 （只计一次）
        $fortDispositorPhaseUran = $fortDispositor . '-7';
        $fortDispositorPhaseNept = $fortDispositor . '-8';
        $fortDispositorPhasePlut = $fortDispositor . '-9';
        if ((isset($planets[$fortDispositor]['phase'][$fortDispositorPhaseUran]) && in_array($planets[$fortDispositor]['phase'][$fortDispositorPhaseUran]['phase_e'], [90, 180], true))
            || (isset($planets[$fortDispositor]['phase'][$fortDispositorPhaseNept]) && in_array($planets[$fortDispositor]['phase'][$fortDispositorPhaseNept]['phase_e'], [90, 180], true))
            || (isset($planets[$fortDispositor]['phase'][$fortDispositorPhasePlut]) && in_array($planets[$fortDispositor]['phase'][$fortDispositorPhasePlut]['phase_e'], [90, 180], true)))
        {
            $l -= 2;
        }
        //⑤福点定位星与金木互容，+4 分 （只计一次）
        // 用本命盘计算行星互容接纳数据
        $receptOrMutualRecept = Astrolog::getInstance()->receptOrMutualRecept($this->astroData['planets']);
        if (!empty($receptOrMutualRecept))
        {
            foreach ($receptOrMutualRecept as $key => $remr)
            {
                if ($key <= 2)
                {
                    foreach ($remr as $rm)
                    {
                        if (($rm['id1'] === $fortDispositor && in_array($rm['id2'], [3, 5], true))
                            || ($rm['id2'] === $fortDispositor && in_array($rm['id1'], [3, 5], true)))
                        {
                            $l += 4;
                            break 2;
                        }
                    }
                }
            }
        }
        if ($l > 8)
        {
            $lv = 5;
        } elseif ($l > 6)
        {
            $lv = 4;
        } elseif ($l > 4)
        {
            $lv = 3;
        } elseif ($l > 1)
        {
            $lv = 2;
        } else
        {
            $lv = 1;
        }

        $levels[] = $lv;

        $result = [
            'desc' => '主题 3：个人财富层次分析',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 获取星体力量强弱标记 取分值最高
     * @param array $ancient
     * @return int
     */
    private function getAncientInfo($ancient = []): int
    {
        // 入庙
        if ($ancient['walls'] === 1)
        {
            $tag = 1;
        }// 失势
        elseif ($ancient['walls'] === 2)
        {
            $tag = 7;
        }// 擢升
        elseif ($ancient['promote'] === 1)
        {
            $tag = 2;
        }// 落陷
        elseif ($ancient['promote'] === 2)
        {
            $tag = 6;
        }// 三分
        elseif ($ancient['trisection'] === 1)
        {
            $tag = 3;
        }// 界主
        elseif ($ancient['extent'] === 1)
        {
            $tag = 4;
        }// 十度
        elseif ($ancient['period'] === 1)
        {
            $tag = 5;
        }// 游走 migration
        else
        {
            $tag = 8;
        }
        return $tag;
    }

    /**
     * 获取相位类型 0中、60/120吉、90/180凶
     * @param int $deg
     * @return int
     */
    private function getPhaseType(int $deg = 0): int
    {
        switch ($deg)
        {
            case 0:
                $phaseType = 2;
                break;
            case 60:
            case 120:
                $phaseType = 0;
                break;
            default:
                $phaseType = 1;
                break;
        }
        return $phaseType;
    }

    /**
     * 获取宫主星 & 古典宫主星的力量强弱
     * @param int $hid
     * @param array $res
     * @param int $flag
     */
    private function getHouseProtectInHouseAncientPowerPhaseTypes(int $hid = null, array &$res = [], int $flag = 0): void
    {
        if ($hid !== null)
        {
            $houses = $this->astroData['houses'];
            $planets = $this->astroData['planets'];
            $houseProtectId = $houses[$hid]['protect_id'];// 现代宫主星
            $houseProtectAncientId = $houses[$hid]['protect_ancient_id'];// 古典宫主星
            $f1 = (int)($flag / 2);
            $f2 = ($flag % 2);
            // 宫主星：古典&现代
            $res[] = 100100000000 + $f1 * 1000000 + $f2 * 10000 + $houseProtectId;
            if ($flag === 0 && $hid === 2)
            {
                // 现代宫主飞宫
                $res[] = 10010000010000 + $f2 * 1000000 + $houseProtectId * 100 + $planets[$houseProtectId]['in_house_id'] - 1;
            } else
            {
                $res[] = 100100000100 + $f1 * 1000000 + $f2 * 10000 + $planets[$houseProtectId]['in_house_id'] - 1;
            }
            // 古典宫主星力量强弱
            // 力量强弱 1入庙 2擢升 3三分 4界主 5十度 6失势(落陷) 7落陷（入弱） 8游走
            //10010100020000
            $res[] = 10010000020000 + $f1 * 100000000 + $f2 * 1000000 + $houseProtectAncientId * 100 + $this->getAncientInfo($planets[$houseProtectAncientId]['ancient']) - 1;

            // 与另外的古典六星间的相位类型
            $phaseNum = 0;
            $phases = [];
            if (!empty($planets[$houseProtectAncientId]['phase']))
            {
                foreach ($planets[$houseProtectAncientId]['phase'] as $phase)
                {
                    if ($phase['id'] < 7 && in_array($phase['phase_e'], [0, 60, 90, 120, 180], true))
                    {
                        // 若成相星体id比宫主星id大  则 -1 后 再 * 100 为CODE码中需要的
                        $ln = $phase['id'] > $houseProtectAncientId ? $phase['id'] - 1 : $phase['id'];
                        $phases[] = ['ln' => $ln, 'phase_orb' => $phase['phase_e'], 'type' => $this->getPhaseType($phase['phase_e'])];
                        $phaseNum++;
                    }
                }
            }
            $phases = resort($phases, 'phase_orb', 'ASC');
            if ($flag > 1)
            {
                // 选择最紧密的1个相位
                $phases = array_slice($phases, 0, 1);
            } else
            {
                // 选择最紧密的2个相位
                $phases = array_slice($phases, 0, 2);
            }
            if ($phaseNum > 0)
            {
                foreach ($phases as $ph)
                {
                    $res[] = 1001000003000000 + $f1 * 10000000000 + $f2 * 100000000 + $houseProtectAncientId * 10000 + $ph['ln'] * 100 + $ph['type'];
                }
            }// 空相
            else
            {
                $res[] = 10010000030006 + $f1 * 100000000 + $f2 * 1000000 + $houseProtectAncientId * 100;
            }
        }
    }

    /**
     * 图 1：你一生的感情运势高低
     * 建议自 12岁开始-100岁区间
     * 做一个高低曲线图，重点标注 X 年较高，X 年较低
     * 每10年取 2-4个年份进行重点标注，考虑到有些人十年一运都未必有好的感情运，尽量保证取 2 个。（需要曲线图逻辑）
     */
    protected function getFeelingsCurveData(): array
    {
        $levels = [];

        $Astrolog = Astrolog::getInstance();

        $recode = $Astrolog->getRecode1();

        $file = 'solar_return_rid:' . $recode['id'] . '.json';

        $dir = 'feelings';

        $filePath = RUNTIME_PATH . $dir . DS;

        if (file_exists($filePath . $file))
        {
            $this->solarReturnData = json_decode(file_get_contents($filePath . $file), true);
        } else
        {
            $this->solarReturnData = [];
            $setting = ['solar_return' => $this->setting2['solar_return']];

            $Astrolog = $Astrolog->setIsAstrolabe(false)->setUserSetting($setting)->setGetDatas(['solar_return']);

            $advance = $recode;
            $advance['year'] += 12;
            $advance['month']++;
            if ($advance['month'] > 12)
            {
                $advance['year']++;
                $advance['month'] = 1;
            }

            $returnTimes = [];
            /**
             * 获取八十九年的太阳返照盘数据
             */
            for ($start = 1; $start <= 89;)
            {
                $tmp = $Astrolog->setAdvance($advance)->getAstroDatas()->getDatas('solar_return');
                if (empty($returnTimes) || !in_array($tmp['return_time'], $returnTimes, true))
                {
                    $start++;
                    $this->solarReturnData[] = $tmp;
                    $returnTimes[] = $tmp['return_time'];
                }
                ++$advance['year'];
            }
            // 写入文件
            Util::createFile($file, json_encode($this->solarReturnData, true), $dir);
        }

        // 开始遍历12-100岁年的日返盘数据
        foreach ($this->solarReturnData as $y => $data)
        {
            $levels[] = $this->calcForGetFeelings('section1', $data);
        }

        $result = [
            'desc' => '图 1：你一生的感情运势高低',
            'content_list' => [],
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 主题 1：对恋爱的基本态度
     */
    protected function getFeelingsSection1(): array
    {
        //（AxBxC求和+12个宫头D求和+E求和）/X 单独设置脚本
        //①（男命/女命）对爱情的基本态度（120字）
        $planets = $this->astroData['planets'];
        // 太阳落星座宫位
        $tags[] = 110000000000 + ($planets[0]['in_sign_id'] - 1) * 100 + $planets[0]['in_house_id'] - 1;
        // 月亮落星座宫位
        $tags[] = 110000010000 + ($planets[1]['in_sign_id'] - 1) * 100 + $planets[1]['in_house_id'] - 1;
        // 金星落星座宫位
        $tags[] = 110000020000 + ($planets[3]['in_sign_id'] - 1) * 100 + $planets[3]['in_house_id'] - 1;
        // 上升落星座
        $tags[] = 1100000300 + $planets[ASC]['in_sign_id'] - 1;
        //②正面有利影响（150字）+影响星级（图，需要逻辑算法）
        // 太阳落星座
        $tags[] = 1100010000 + $planets[0]['in_sign_id'] - 1;
        // 月亮落星座
        $tags[] = 1100010100 + $planets[1]['in_sign_id'] - 1;
        // 水星落星座
        $tags[] = 1100010200 + $planets[2]['in_sign_id'] - 1;
        // 上升落星座
        $tags[] = 1100010300 + $planets[ASC]['in_sign_id'] - 1;
        // 金星落星座
        $tags[] = 1100010400 + $planets[3]['in_sign_id'] - 1;
        // 火星落星座
        $tags[] = 1100010500 + $planets[4]['in_sign_id'] - 1;
        // 木星落宫
        $tags[] = 1100010600 + $planets[5]['in_house_id'] - 1;
        // 土星落宫
        $tags[] = 1100010700 + $planets[6]['in_house_id'] - 1;
        // 天王星落宫
        $tags[] = 1100010800 + $planets[7]['in_house_id'] - 1;
        // 海王星落宫
        $tags[] = 1100010900 + $planets[8]['in_house_id'] - 1;
        // 冥王星落宫
        $tags[] = 1100011000 + $planets[9]['in_house_id'] - 1;

        // 影响星级的算法中取太阳、月亮、金星、上升数值来根据影响星级总算法公式来计算
        //（AxBxC求和+12个宫头D求和+E求和）/X （这部分看是要用更想对精确的算法还是和内容完全统一）
        $levels[] = $this->calcForGetFeelings('section2', $this->astroData);

        //③不利或隐患影响（150字）+影响星级（图，需要逻辑算法）
        // 太阳落星座
        $tags[] = 1100020000 + $planets[0]['in_sign_id'] - 1;
        // 月亮落星座
        $tags[] = 1100020100 + $planets[1]['in_sign_id'] - 1;
        // 水星落星座
        $tags[] = 1100020200 + $planets[2]['in_sign_id'] - 1;
        // 上升落星座
        $tags[] = 1100020300 + $planets[ASC]['in_sign_id'] - 1;
        // 金星落星座
        $tags[] = 1100020400 + $planets[3]['in_sign_id'] - 1;
        // 火星落星座
        $tags[] = 1100020500 + $planets[4]['in_sign_id'] - 1;
        // 木星落宫
        $tags[] = 1100020600 + $planets[5]['in_house_id'] - 1;
        // 土星落宫
        $tags[] = 1100020700 + $planets[6]['in_house_id'] - 1;
        // 天王星落宫
        $tags[] = 1100020800 + $planets[7]['in_house_id'] - 1;
        // 海王星落宫
        $tags[] = 1100020900 + $planets[8]['in_house_id'] - 1;
        // 冥王星落宫
        $tags[] = 1100021000 + $planets[9]['in_house_id'] - 1;
        // 影响星级的算法中取太阳、月亮、金星、上升数值来根据影响星级总算法公式来计算
        //（AxBxC求和+12个宫头D求和+E求和）/X
        // 其中AxBxC求和 只计算日月金三颗星体，D求和只取上升
        // levels转换成1-5🌟
        $levels[] = $this->calcForGetFeelings('section3', $this->astroData);

        //（男命/女命）对爱情的安全感来源，关键词*4 组
        // 太阳落星座
        $tags[] = 1100030000 + $planets[0]['in_sign_id'] - 1;
        // 太阳落宫
        $tags[] = 1100030100 + $planets[0]['in_house_id'] - 1;
        // 月亮落星座
        $tags[] = 1100030200 + $planets[1]['in_sign_id'] - 1;
        // 月亮落宫
        $tags[] = 1100030300 + $planets[1]['in_house_id'] - 1;

        $result = [
            'desc' => '主题 1：对恋爱的基本态度',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 主题 2：喜欢及恋爱的异性类型及对方条件
     */
    protected function getFeelingsSection2(): array
    {
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        // ①对方的类型
        //算法：优先看太阳是否落入7宫，如果有就取太阳，没有取月亮，月亮没有取金星，金星没有取下降落座
        if ($planets[0]['in_house_id'] === 7)
        {
            $tags[] = 1101000000 + $planets[0]['in_sign_id'] - 1;
        } elseif ($planets[1]['in_house_id'] === 7)
        {
            $tags[] = 1101000100 + $planets[1]['in_sign_id'] - 1;
        } elseif ($planets[3]['in_house_id'] === 7)
        {
            $tags[] = 1101000200 + $planets[3]['in_sign_id'] - 1;
        } else
        {
            $tags[] = 1101000300 + $planets[DES]['in_sign_id'] - 1;
        }
        //② 条件
        //算法：优先看太阳是否落入4宫，如果有就取太阳，没有取水星，水星没有取金星，金星没有取天底落座
        if ($planets[0]['in_house_id'] === 4)
        {
            $tags[] = 1101010000 + $planets[0]['in_sign_id'] - 1;
        } elseif ($planets[2]['in_house_id'] === 4)
        {
            $tags[] = 1101010100 + $planets[2]['in_sign_id'] - 1;
        } elseif ($planets[3]['in_house_id'] === 4)
        {
            $tags[] = 1101010200 + $planets[3]['in_sign_id'] - 1;
        } else
        {
            $tags[] = 1101010300 + $planets[DES]['in_sign_id'] - 1;
        }
        //③ 相识途径
        //算法：3宫主落入宫位
        $tags[] = 1101020000 + $houses[3]['protect_inhouse_id'] - 1;

        $result = [
            'desc' => '主题 2：喜欢及恋爱的异性类型及对方条件',
            'content_list' => $tags,
            'levels' => []
        ];
        return $result;
    }

    /**
     * 主题 3：恋爱过程中出现的顺利、困难或阻碍
     */
    protected function getFeelingsSection3(): array
    {
        $planets = $this->astroData['planets'];
        //①异性桃花多寡
        //算法：优先看太阳是否落入7宫，如果有就取太阳，没有取月亮，月亮没有取金星，金星没有取下降落座
        if ($planets[0]['in_house_id'] === 7)
        {
            $tags[] = 1102000000 + $planets[0]['in_sign_id'] - 1;
        } elseif ($planets[1]['in_house_id'] === 7)
        {
            $tags[] = 1102000100 + $planets[1]['in_sign_id'] - 1;
        } elseif ($planets[3]['in_house_id'] === 7)
        {
            $tags[] = 1102000200 + $planets[3]['in_sign_id'] - 1;
        } else
        {
            $tags[] = 1102000300 + $planets[DES]['in_sign_id'] - 1;
        }
        //②爱情是否顺遂
        //A、顺利影响分析
        //A优先看太阳是否落入7宫，如果有就取太阳，没有取月亮，月亮没有取金星，金星没有取下降落座 4x12
        //B木星落入宫及星座 12x12
        if ($planets[0]['in_house_id'] === 7)
        {
            $tags[] = 110201000000 + $planets[0]['in_sign_id'] - 1;
        } elseif ($planets[1]['in_house_id'] === 7)
        {
            $tags[] = 110201000100 + $planets[1]['in_sign_id'] - 1;
        } elseif ($planets[3]['in_house_id'] === 7)
        {
            $tags[] = 110201000200 + $planets[3]['in_sign_id'] - 1;
        } else
        {
            $tags[] = 110201000300 + $planets[DES]['in_sign_id'] - 1;
        }
        // 木星落星座宫位
        $tags[] = 11020100040000 + ($planets[5]['in_sign_id'] - 1) * 100 + $planets[5]['in_house_id'] - 1;
        // 影响星级（图，需要逻辑算法）；
        //算法：（AxBxC结果全部求和+D全部求和+E全部求和）/常量X
        // levels转换成1-5🌟
        $levels[] = $this->calcForGetFeelings('section4', $this->astroData);

        //B、困难影响分析
        //A优先看太阳是否落入7宫，如果有就取太阳，没有取月亮，月亮没有取金星，金星没有取下降落座（A为250字）4x12x250字
        //B土星落入宫及星座 12x12x50=1200字（B为50字）
        if ($planets[0]['in_house_id'] === 7)
        {
            $tags[] = 110201010000 + $planets[0]['in_sign_id'] - 1;
        } elseif ($planets[1]['in_house_id'] === 7)
        {
            $tags[] = 110201010100 + $planets[1]['in_sign_id'] - 1;
        } elseif ($planets[3]['in_house_id'] === 7)
        {
            $tags[] = 110201010200 + $planets[3]['in_sign_id'] - 1;
        } else
        {
            $tags[] = 110201010300 + $planets[DES]['in_sign_id'] - 1;
        }
        // 土星落星座宫位
        $tags[] = 11020101040000 + ($planets[6]['in_sign_id'] - 1) * 100 + $planets[6]['in_house_id'] - 1;

        // 影响星级（图，需要逻辑算法）
        //（AxBxC结果全部求和+D全部求和+E全部求和）/常量X
        $levels[] = $this->calcForGetFeelings('section5', $this->astroData);

        $result = [
            'desc' => '主题 3：恋爱过程中出现的顺利、困难或阻碍',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 主题 4：和Ta 恋爱相处的方式建议
     */
    protected function getFeelingsSection4(): array
    {
        $planets = $this->astroData['planets'];
        // 性别处理
        $sexTag = (int)$this->recode['type'] === 1 ? 0 : 1;
        $f = $sexTag * 10000;
        //你可以这么做
        // 1.太阳落星座
        $tags[] = 110300000000 + $f + $planets[0]['in_sign_id'] - 1;
        // 2.水星落星座
        $tags[] = 110300000100 + $f + $planets[2]['in_sign_id'] - 1;
        // 3.月亮落星座
        $tags[] = 110300000200 + $f + $planets[1]['in_sign_id'] - 1;
        // 4.火星落星座
        $tags[] = 110300000300 + $f + $planets[4]['in_sign_id'] - 1;
        // 5.上升落星座
        $tags[] = 110300000400 + $f + $planets[ASC]['in_sign_id'] - 1;
        //你不可以这么
        // 1.太阳落星座
        $tags[] = 110301000000 + $f + $planets[0]['in_sign_id'] - 1;
        // 2.水星落星座
        $tags[] = 110301000100 + $f + $planets[2]['in_sign_id'] - 1;
        // 3.月亮落星座
        $tags[] = 110301000200 + $f + $planets[1]['in_sign_id'] - 1;
        // 4.火星落星座
        $tags[] = 110301000300 + $f + $planets[4]['in_sign_id'] - 1;
        // 5.上升落星座
        $tags[] = 110301000400 + $f + $planets[ASC]['in_sign_id'] - 1;

        $result = [
            'desc' => '主题 4：和Ta 恋爱相处的方式建议',
            'content_list' => $tags,
            'levels' => []
        ];
        return $result;
    }

    /**
     * 个人恋爱格局预测报告 计算分值
     * 算法：
     * 数据源：根据生日信息取每一年的本命日返照盘落点
     * 计算规则：
     * 先天12星座12个A（允许我自定义数值常量）
     * 后天12宫12个B（允许我自定义数值常量）
     * 星体10个C（允许我自定义数值常量）
     * 12个宫头D（允许我自定义数值常量）
     * 日月水金火这五颗星体分别和木土天海冥产生相位关联E（允许我自定义数值常量）——比如日和木有任何相位关系就计为1个自定义常量
     * 自定义数值平局系数X
     * 此算法可以做成通用性的算法，这样不需要技术来解决细节问题。但每个对应的规则，配置文件应该单独设置，比如运势配置、基本态度配置等等
     * （AxBxC结果全部求和+D全部求和+E全部求和）/常量X
     * @param string $config 所属模块
     * @param array $data 日返盘数据
     * @return float|int
     */
    private function calcForGetFeelings(string $config, array $data)
    {
        if (empty($this->setting2[$config]))
        {
            $settingConfig = json_decode('{"section1":{"A":[1,1,1,1,1,1,1,1,1,1,1,1],"B":[9,5,8,6,8,3,9,5,7,6,8,3],"C":[0,0,0,0,0,0,0,8,2,7,3,9],"D":[0,0,0,0,0,0,0,0,0,0,0,0],"E":[{"0-5":0},{"0-6":0},{"0-7":0},{"0-8":0},{"0-9":0},{"1-5":0},{"1-6":0},{"1-7":0},{"1-8":0},{"1-9":0},{"2-5":0},{"2-6":0},{"2-7":0},{"2-8":0},{"2-9":0},{"3-5":0},{"3-6":0},{"3-7":0},{"3-8":0},{"3-9":0},{"4-5":0},{"4-6":0},{"4-7":0},{"4-8":0},{"4-9":0}],"X":1},"section2":{"A":[6,8,3,7,9,1,6,8,2,7,5,3],"B":[10,7,2,6,8,3,10,8,1,6,7,3],"C":[9,8,5,7,3,0,0,0,0,0,0,0],"D":[0,0,0,0,0,0,0,0,0,0,0,0],"E":[{"0-5":0},{"0-6":0},{"0-7":0},{"0-8":0},{"0-9":0},{"1-5":0},{"1-6":0},{"1-7":0},{"1-8":0},{"1-9":0},{"2-5":0},{"2-6":0},{"2-7":0},{"2-8":0},{"2-9":0},{"3-5":0},{"3-6":0},{"3-7":0},{"3-8":0},{"3-9":0},{"4-5":0},{"4-6":0},{"4-7":0},{"4-8":0},{"4-9":0}],"X":1},"section3":{"A":[2,7,6,3,8,7,3,9,1,4,6,5],"B":[10,7,2,6,8,3,10,8,1,6,7,3],"C":[9,8,5,7,3,0,0,0,0,0,0,0],"D":[0,0,0,0,0,0,0,0,0,0,0,0],"E":[{"0-5":0},{"0-6":0},{"0-7":0},{"0-8":0},{"0-9":0},{"1-5":0},{"1-6":0},{"1-7":0},{"1-8":0},{"1-9":0},{"2-5":0},{"2-6":0},{"2-7":0},{"2-8":0},{"2-9":0},{"3-5":0},{"3-6":0},{"3-7":0},{"3-8":0},{"3-9":0},{"4-5":0},{"4-6":0},{"4-7":0},{"4-8":0},{"4-9":0}],"X":1},"section4":{"A":[7,8,2,6,9,6,3,9,4,5,8,1],"B":[10,7,2,6,8,3,10,8,1,6,7,3],"C":[9,8,5,7,3,0,0,0,0,0,0,0],"D":[0,0,0,0,0,0,0,0,0,0,0,0],"E":[{"0-5":0},{"0-6":0},{"0-7":0},{"0-8":0},{"0-9":0},{"1-5":0},{"1-6":0},{"1-7":0},{"1-8":0},{"1-9":0},{"2-5":0},{"2-6":0},{"2-7":0},{"2-8":0},{"2-9":0},{"3-5":0},{"3-6":0},{"3-7":0},{"3-8":0},{"3-9":0},{"4-5":0},{"4-6":0},{"4-7":0},{"4-8":0},{"4-9":0}],"X":1},"section5":{"A":[2,8,8,6,9,9,3,8,9,4,8,7],"B":[7,1,4,4,5,3,1,9,7,4,9,2],"C":[9,8,5,7,3,0,0,0,0,0,0,0],"D":[21,32,13,41,50,16,27,18,29,30,41,12],"E":[{"0-5":5},{"0-6":5},{"0-7":4},{"0-8":9},{"0-9":11},{"1-5":-8},{"1-6":-9},{"1-7":1},{"1-8":1},{"1-9":1},{"2-5":2},{"2-6":1},{"2-7":1},{"2-8":1},{"2-9":3},{"3-5":3},{"3-6":-1},{"3-7":8},{"3-8":1},{"3-9":1},{"4-5":8},{"4-6":-1},{"4-7":7},{"4-8":2},{"4-9":1}],"X":1}}', true);
//            $settingConfig = json_decode(Env::get('report.feelings'), true);
            $this->setting2 = array_merge($this->setting2, $settingConfig);
        }
        $setting = $this->setting2[$config];
        /**
         * $tmp1 AxBxC结果全部求和
         * $tmp2 D全部求和
         * $tmp3 E全部求和
         */
        $tmp1 = $tmp2 = $tmp3 = 0;
        for ($i = 0; $i < 10; $i++)
        {
            $planet = $data['planets'][$i];
            $a = $setting['A'][$planet['in_sign_id'] - 1];
            $b = $setting['B'][$planet['in_house_id'] - 1];
            $c = $setting['C'][$i];
            $tmp1 += $a * $b * $c;
            if (!empty($planet['phase']))
            {
                foreach ($planet['phase'] as $item => $phase)
                {
                    $ph1 = $i . '-' . $phase['id'];
                    $ph2 = $phase['id'] . '-' . $i;
                    $tmp3 += ($setting['E'][$ph1] ?? ($setting['E'][$ph2] ?? 0));
                }
            }
        }
        for ($j = 1; $j < 13; $j++)
        {
            $tmp2 += $setting['D'][$data['houses'][$i]['in_sign_id'] - 1];
        }
        $score = (int)($setting['X'] / 1) !== 0 ? (float)(($tmp1 + $tmp2 + $tmp3) / $setting['X']) : 0;
        return (string)$score;
    }

    /**
     * 事业报告 图 1：你一生的事业运势高低
     */
    protected function getCarrerCurveData(): array
    {
        // 12岁-100岁
        //做一个高低曲线图，重点标注 X 年较高，X 年较低
        //每10年取 2-4个年份进行重点标注，考虑到有些人十年一运都未必有好的事业运，尽量保证取 2 个。（需要曲线图逻辑）
        $levels = [];
        foreach ($this->firdariaData as $k => $firdaria)
        {
            // 1、确定年运行星：按照法达讲不同年份分配到不同行星，每1.5年有一个大运星和一个小运星。
            $main = $firdaria['firdaria']['main_luck'];
            $sub = $firdaria['firdaria']['sub_luck'];
            $p1 = $firdaria['planets'][$main]['ancient']['power'];
            $p2 = $firdaria['planets'][$sub]['ancient']['power'];
            //南交射手，北交双子为正5分
            //南交双子。北交射手为-5分
            if ($main === 12)
            {
                if ($firdaria['planets'][$main]['in_sign_id'] === 3)
                {
                    $p1 = 5;
                    $p2 = -5;
                } elseif ($firdaria['planets'][$main]['in_sign_id'] === 9)
                {
                    $p1 = -5;
                    $p2 = 5;
                }
            }
            // 2、确定单个行星得分P：按照先天尊贵给行星赋分，但是，如果是金星木星为+1分，火星土星默认-1分，如果行星是第十宫宫主星+2分，落入第十宫的行星+1分。
            ($main === 3 || $main === 5) && $p1++;
            ($main === 4 || $main === 6) && $p1--;
            ($sub === 3 || $sub === 5) && $p2++;
            ($sub === 4 || $sub === 6) && $p2--;
            $firdaria['houses'][10]['protect_ancient_id'] === $main && $p1 += 2;
            $firdaria['planets'][$main]['in_house_id'] === 10 && $p1++;
            $firdaria['houses'][10]['protect_ancient_id'] === $sub && $p2 += 2;
            $firdaria['planets'][$sub]['in_house_id'] === 10 && $p2++;
            //3、计算大运区间分D，（使用整宫制）
            // （1）第十宫宫主三分主星主管年份为12-42岁，42-72岁，72岁以后，三个区间，
            // (2）以十宫主三分主星的档次分为5，0，-5分三个等级，落入角宫（整宫制）且三分主星先天尊贵为正，为5分档，落入果宫0分且得分为负为-5分档，其余为0分档。
            $house10ProtectAncientTrisection = $firdaria['planets'][$firdaria['houses'][10]['protect_ancient_id']]['ancient']['or_trisection_planet_id'];
            if ($k >= 72)
            {
                $h10p = $house10ProtectAncientTrisection[2];
            } elseif ($k >= 42)
            {
                $h10p = $house10ProtectAncientTrisection[1];
            } else
            {
                $h10p = $house10ProtectAncientTrisection[0];
            }
            // 落入角宫
            $h10pInHouseType = $firdaria['planets'][$h10p]['in_house_id'] % 3;
            if ($h10pInHouseType === 1 && $firdaria['planets'][$h10p]['ancient']['power'] > 0)
            {
                $d = 5;
            } elseif ($h10pInHouseType === 0 && $firdaria['planets'][$h10p]['ancient']['power'] < 0)
            {
                $d = -5;
            } else
            {
                $d = 0;
            }
            //4、计算单独年得分：取行星先天能量得分（假设大运行星为P1，小运为P2），P1*0.3+P2*0.7+D（按照实际年级取相应得分）=最终得分，然后做曲线。
            $score = $p1 * 0.3 + $p2 * 0.7 + $d;
            $levels[] = (string)$score;
        }

        $result = [
            'desc' => '图 1：你一生的事业运势高低',
            'content_list' => [],
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 事业报告 主题 1：你对工作和事业的基本态度
     */
    protected function getCarrerReportSection1(): array
    {
        $tags = $levels = [];
        //对工作和事业的①基本态度（150 字）
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        $house10ProtectAncient = $houses[10]['protect_ancient_id'];
        $house10ProtectAncientPower = $planets[$house10ProtectAncient]['ancient']['power'];
        //对事业的基本态度=十宫头落十二星座 75字*12
        $tags[] = 1200000000 + ($houses[10]['in_sign_id'] - 1);
        //对工作的基本态度=第六宫宫头落星座 75字*12
        $tags[] = 1200000100 + ($houses[6]['in_sign_id'] - 1);
        //②正面有利影响（100 字）+ 影响星级（图，需要逻辑算法）
        // 逻辑
        //1、选择第十宫宫主星，（选用古典宫主星，太阳到土星7个行星）
        //2、对除宫主星之外的其他9个行星得分（三王星只计算庙落旺陷）进行排序，从最高到最低。
        //3、判断宫主星相位
        // 按照太阳到冥王九个行星（除去宫主星）对第十宫宫主星的相位,优先选择准确成相位的，好的两个，坏的两个。分成两类，30 60 120为正面影响，90 180为负面影响，0度判断行星尊贵，尊贵大于0分为正面影响，反之为负面影响
        $houses10ProtectPhase = $planets[$house10ProtectAncient]['phase'];
        $goods = $bads = [];
        // TODO 获取元素
//        $fixedPhase = $this->fixedPhase($this->astroData);

        if (!empty($houses10ProtectPhase))
        {
            foreach ($houses10ProtectPhase as $phase)
            {
                if ($phase['id'] < 10)
                {
                    $ti = [
                        'id' => $phase['id'],
                        'phase_orb' => $phase['phase_orb'],
                        'power' => $planets[$phase['id']]['ancient']['power']
                    ];
                    // 正面影响
                    if (in_array($phase['phase_e'], [30, 60, 120], true))
                    {
                        $goods[] = $ti;
                    }// 负面影响
                    elseif (in_array($phase['phase_e'], [90, 180], true))
                    {
                        $bads[] = $ti;
                    }// 0度判断行星尊贵 正分为正面 否则为负面影响
                    elseif ($phase['phase_e'] === 0)
                    {
                        // 正面影响
                        if ($planets[$phase['id']]['ancient']['power'] > 0)
                        {
                            $goods[] = $ti;
                        }// 负面影响
                        else
                        {
                            $bads[] = $ti;
                        }
                    }
                }
            }
        }
        $countGoods = count($goods);
        $countBads = count($bads);
        if ($countGoods > 1)
        {
            // 优先选择准确成相的
            $sortByOrbGoods = resort($goods, 'phase_orb', 'DESC');
            $goods = array_slice($sortByOrbGoods, 0, 2);
        }
        if ($countBads > 1)
        {
            // 优先选择准确成相的 不利的（值越小表示越不利）
            $sortByOrbBads = resort($bads, 'phase_orb', 'ASC');
            $bads = array_slice($sortByOrbBads, 0, 2);
        }

        // 不足两个相位
        if ($countGoods < 2 || $countBads < 2)
        {
            $signPhaseConfig = [
                'p1' => [$houses[10]['protect_id']],
                'p2' => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
                'asp' => [0 => 0, 30 => 1, 60 => 2, 90 => 3, 120 => 4, 150 => 5, 180 => 6],
            ];
            $goodsTemp = [];
            $badsTemp = [];
            $goodsId = array_column($goods, 'id');
            $badsId = array_column($bads, 'id');

            foreach ($signPhaseConfig['p1'] as $k1 => $p1)
            {
                foreach ($signPhaseConfig['p2'] as $p2)
                {
                    $p1Phasep2 = $p1 . '-' . $p2;// 过滤已有相位
                    if ($p2 !== $p1 && !isset($houses10ProtectPhase[$p1Phasep2]))
                    {
                        $p1InSign = $planets[$p1]['in_sign_id'];
                        $p2InSign = $planets[$p2]['in_sign_id'];
                        foreach ($signPhaseConfig['asp'] as $ph => $asp)
                        {
                            $p1PhaseSign1 = $p1InSign + $asp;
                            $p1PhaseSign2 = $p1InSign - $asp;
                            $p1PhaseSign2 = $p1PhaseSign2 < 1 ? $p1PhaseSign2 + 12 : $p1PhaseSign2;
                            if ($p2InSign === $p1PhaseSign1 || $p2InSign === $p1PhaseSign2)
                            {
                                $ti = [
                                    'id' => $p2,
                                    'power' => $planets[$p2]['ancient']['power']
                                ];
                                // 行星一与行星2形成星座制相位
                                if (in_array($ph, [30, 60, 120], true) && !in_array($p2, $goodsId) && $countGoods < 2)
                                {
                                    $goodsTemp[] = $ti;
                                    $goodsId[] = $p2;
                                } elseif (in_array($ph, [90, 180], true) && !in_array($p2, $badsId) && $countBads < 2)
                                {
                                    $badsTemp[] = $ti;
                                    $badsId[] = $p2;
                                } elseif ($ph === 0)
                                {
                                    if ($ti['power'] > 0 && !in_array($p2, $goodsId))
                                    {
                                        $goodsTemp[] = $ti;
                                        $goodsId[] = $p2;
                                    } elseif ($ti['power'] <= 0 && !in_array($p2, $badsId))
                                    {
                                        $badsTemp[] = $ti;
                                        $badsId[] = $p2;

                                    }
                                }
                            }
                        }
                    }

                }
            }
            $goodsTemp = resort($goodsTemp, 'power', 'DESC');
            $badsTemp = resort($badsTemp, 'power', 'ASC');
            $goodsTemp = array_slice($goodsTemp, 0, 2 - $countGoods);
            $badsTemp = array_slice($badsTemp, 0, 2 - $countBads);
            $goods = array_merge($goods, $goodsTemp);
            $bads = array_merge($bads, $badsTemp);
        }
        $goodsLevel = 0;
        $badsLevel = 0;
        // 3.1如果和宫主星没有两个相位，扩大到整个星座相位制
        // 比如第十宫宫主星在白羊座，那么射手座的行星和狮子座的行星就是和第十宫宫主星成120度
        // 3.2一直到选出两个正面相位，两个负面相位为止。如果有多个相位按照第二步对行星尊贵评分排序，好相位选择最高得分行星，坏影响选择最低行星得分。
        // 4、判断得分等级
        //有利等级：前两个正面相位行星尊贵得分相加
        //>15   >12    >9    >6    <6
        //不利等级：前两个负面相位行星尊贵得分相加
        //<-15    <-12    <-9    <-6    <0
        if (isset($goods[0]))
        {
            $tags[] = 1200010000 + $goods[0]['id'];
            $goodsLevel += $goods[0]['power'];
        }// 若没有正面，则取宫主星
        else
        {
            if ($house10ProtectAncientPower > 0)
            {
                $tags[] = 1200010000 + $house10ProtectAncient;
                $goodsLevel += $house10ProtectAncientPower;
            } else
            {
                $tags[] = 1200010010;
            }
        }
        if (isset($goods[1]))
        {
            $tags[] = 1200010000 + $goods[1]['id'];
            $goodsLevel += $goods[1]['power'];
        }
        $badStatus = false;
        if (isset($bads[0]))
        {
            $badsLevel += $bads[0]['power'];
        } else
        {
            if ($house10ProtectAncientPower < 0)
            {
                $bads[0] = [
                    'id' => $house10ProtectAncient
                ];
                $badsLevel += $house10ProtectAncientPower;
            } else
            {
                $badStatus = true;
            }
        }
        if (isset($bads[1]))
        {
            $badsLevel += $bads[1]['power'];
        }

        if ($goodsLevel > 15)
        {
            $levels[] = 5;
        } elseif ($goodsLevel > 12)
        {
            $levels[] = 4;
        } elseif ($goodsLevel > 9)
        {
            $levels[] = 3;
        } elseif ($goodsLevel > 6)
        {
            $levels[] = 2;
        } else
        {
            $levels[] = 1;
        }

        //金星木星落入第十宫，2*50字
        if ($planets[3]['in_house_id'] === 10)
        {
            $tags[] = 12000101;
        }
        if ($planets[5]['in_house_id'] === 10)
        {
            $tags[] = 12000102;
        }
        //金星木星落入第六宫，2*50字
        if ($planets[3]['in_house_id'] === 6)
        {
            $tags[] = 12000103;
        }
        if ($planets[5]['in_house_id'] === 6)
        {
            $tags[] = 12000104;
        }
        // 1.如果没有不利影响，如果宫主星是负分，直接选这个行星的解释，反之亦然，2.如果还没有,我好的坏的都写一段，实在没有就调这个就调取
        //③不利或隐患影响（100 字）+ 影响星级（图，需要逻辑算法）
        //先天小于0分的行星负面的影响7*100字
        if (isset($bads[0]))
        {
            $tags[] = 1200020000 + $bads[0]['id'];
        } elseif ($badStatus === true)
        {
            $tags[] = 1200020010;
        }
        if (isset($bads[1]))
        {
            $tags[] = 1200020000 + $bads[1]['id'];
        }
        if ($badsLevel < -15)
        {
            $levels[] = 5;
        } elseif ($badsLevel < -12)
        {
            $levels[] = 4;
        } elseif ($badsLevel < -9)
        {
            $levels[] = 3;
        } elseif ($badsLevel < -6)
        {
            $levels[] = 2;
        } else
        {
            $levels[] = 1;
        }
        //火星土星落入第十宫负面影响，2*50字
        if ($planets[4]['in_house_id'] === 10)
        {
            $tags[] = 12000201;
        }
        if ($planets[6]['in_house_id'] === 10)
        {
            $tags[] = 12000202;
        }
        //火星土星落入第六宫负面影响，2*50字
        if ($planets[4]['in_house_id'] === 6)
        {
            $tags[] = 12000203;
        }
        if ($planets[6]['in_house_id'] === 6)
        {
            $tags[] = 12000204;
        }

        $result = [
            'desc' => '主题 1：事业观念综述',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 事业报告 主题 2：你天生的职业倾向与类别
     */
    protected function getCarrerReportSection2(): array
    {
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        $tags = [];
        //①比较适合你从业的行业领域描述：（100字）
        //时间准确：Mc所落星座决定职业领域 12*100
        $tags[] = 1201000000 + $planets[MC]['in_sign_id'] - 1;
        //②比较适合你的职业岗位描述：（100字）
        //从太阳-土星中，选择先天得分最高的两个行星，按照这个两个行星描述适合职业岗位，7*100
        $powers = [];
        for ($i = 0; $i < 7; $i++)
        {
            $powers[] = [
                'id' => $i,
                'power' => $planets[$i]['ancient']['power']
            ];
        }
        $powers = resort($powers, 'power', 'DESC');
        $tags[] = 1201010000 + $powers[0]['id'];
        $tags[] = 1201010000 + $powers[1]['id'];
        //③工作环境层面描述（200字）
        //准确时间：第六宫落入星座+六宫(古典宫主星)飞星+第六宫内行星（现代十大行星），12*50字+12*50字+10*50字
        $tags[] = 1201020000 + $houses[6]['in_sign_id'] - 1;
        // 6宫飞星
        $tags[] = 1201020100 + $houses[6]['protect_ancient_inhouse_id'] - 1;
        // 6宫宫内星 优选前两个先天得分最高的星体
        if (!empty($houses[6]['in_house_area_planet_info']))
        {
            $hps = [];
            foreach ($houses[6]['in_house_area_planet_info'] as $hpsp)
            {
                $hps[] = [
                    'id' => $hpsp['id'],
                    'power' => $planets[$hpsp['id']]['ancient']['power']
                ];
            }
            if (!empty($hps))
            {
                $hps = resort($hps, 'power', 'DESC');

                $tags[] = 1201020200 + $hps[0]['id'];
                if (isset($hps[1]))
                {
                    $tags[] = 1201020200 + $hps[1]['id'];
                }
            }
        }
        //④领导交流层面描述（200字）
        //1、水星星座，沟通模式
        $tags[] = 1201030000 + $planets[2]['in_sign_id'] - 1;
        // 2、太阳和土星（整个星座相位制）和其他行星（现代行星9个）的相位，判断对权力的态度，11月21日修改2.4.4土星与其他9个行星相位（负面）对权威的负面态度（50*9）删除土星和三王星相位，也就是九个行星变成6个，正面负面土星和三王星相位都删除。
        $signPhaseConfig = [
            'p1' => [0, 6],
            'p2' => [
                [1, 2, 3, 4, 5, 6, 7, 8, 9],
                [0, 1, 2, 3, 4, 5],
            ],
            'asp' => [0 => 0, 30 => 1, 60 => 2, 90 => 3, 120 => 4, 150 => 5, 180 => 6],
        ];
        $phases = [];
        foreach ($signPhaseConfig['p1'] as $k1 => $p1)
        {
            foreach ($signPhaseConfig['p2'][$k1] as $p2)
            {
                $p1InSign = $planets[$p1]['in_sign_id'];
                $p2InSign = $planets[$p2]['in_sign_id'];
                foreach ($signPhaseConfig['asp'] as $ph => $asp)
                {
                    $p1PhaseSign1 = $p1InSign + $asp;
                    $p1PhaseSign2 = $p1InSign - $asp;
                    $p1PhaseSign2 = $p1PhaseSign2 < 1 ? $p1PhaseSign2 + 12 : $p1PhaseSign2;
                    if ($p2InSign === $p1PhaseSign1 || $p2InSign === $p1PhaseSign2)
                    {
                        $p2Power = $planets[$p2]['ancient']['power'];
                        // 行星一于行星2形成星座制相位
                        if ($p1 === 0)
                        {
                            $phases[] = [
                                'power' => $p2Power,
                                'code1' => 1201030100 + $p2 - 1,
                                'code2' => 1201030200 + $p2 - 1
                            ];
//                            $tags[] = 1201030100 + $p2 - 1;
//                            $tags[] = 1201030200 + $p2 - 1;
                        } else
                        {
                            $phases[] = [
                                'power' => $p2Power,
                                'code1' => 1201030300 + $p2,
                                'code2' => 1201030400 + $p2
                            ];
//                            $tags[] = 1201030300 + $p2;
//                            $tags[] = 1201030400 + $p2;
                        }
                    }
                }
            }
        }
        //这里优选一个行星显示
        //1、先判断最强星星，
        //2、按照最强星星相位，和最弱行星相位
        //3、显示唯一的正面+唯一的负面影响。
        if (!empty($phases))
        {
            $phases = resort($phases, 'power', 'DESC');
            $tags[] = $phases[0]['code1'];
            $tags[] = end($phases)['code2'];
        }

        //⑤职场人际层面描述（200 字）
        //十一宫宫头落座12*100
        $tags[] = 1201040100 + $houses[11]['in_sign_id'] - 1;
        //十一宫宫主落宫位12*100
        $tags[] = 1201040200 + $houses[11]['protect_inhouse_id'] - 1;
        //十一宫落入行星10*50 优选前两个先天得分最高的星体
        if (!empty($houses[11]['in_house_area_planet_info']))
        {
            $hps = [];
            foreach ($houses[11]['in_house_area_planet_info'] as $hpsp)
            {
                $hps[] = [
                    'id' => $hpsp['id'],
                    'power' => $planets[$hpsp['id']]['ancient']['power']
                ];
            }
            if (!empty($hps))
            {
                $hps = resort($hps, 'power', 'DESC');

                $tags[] = 1201040000 + $hps[0]['id'];
                if (isset($hps[1]))
                {
                    $tags[] = 1201040000 + $hps[1]['id'];
                }
            }
        }
        //⑥薪资待遇层面描述（200字）
        //1、（二宫主得分+金星得分+木星得分）/2，分5个级别，穷<0，一般0-7，小富>7，富>10，巨富>15。
        $house2ProtectAncientPower = $planets[$houses[2]['protect_ancient_id']]['ancient']['power'];
        $house2ProtectAncientPower += $planets[3]['ancient']['power'];
        $house2ProtectAncientPower += $planets[5]['ancient']['power'];
        $house2ProtectAncientPower /= 2;
        //2、如果福点落二宫，直接提高3分。
        if ($planets[14]['in_house_id'] === 2)
        {
            $house2ProtectAncientPower += 3;
        }
        if ($house2ProtectAncientPower < 0)
        {
            $house2ProtectAncientPowerStatus = 0;
        } elseif ($house2ProtectAncientPower < 7)
        {
            $house2ProtectAncientPowerStatus = 1;
        } elseif ($house2ProtectAncientPower < 10)
        {
            $house2ProtectAncientPowerStatus = 2;
        } elseif ($house2ProtectAncientPower < 15)
        {
            $house2ProtectAncientPowerStatus = 3;
        } else
        {
            $house2ProtectAncientPowerStatus = 4;
        }
        $tags[] = 1201050000 + $house2ProtectAncientPowerStatus;
        //⑦变动或稳定性层面描述（200字）
        //1、判断多数4个以上行星落入变动宫位或者非变动宫位
        //2、MC落入变动星座，或者非变动星座
        //3、月亮或者天王星、冥王星落入第十宫
        //4、月亮或者天王星、冥王星落入第六宫
        //5、土星落入第十宫、第六宫
        $changeNum = 0;
        for ($i = 0; $i < 7; $i++)
        {
            // 落入变动宫位
            if ($planets[$i]['in_house_id'] % 3 === 0)
            {
                ++$changeNum;
            }
        }
        $planetsInChangeHouseStatus = $changeNum > 4 ? 1 : 0;
        $tags[] = 1201060000 + $planetsInChangeHouseStatus;
        // MC落入变动星座 4
        // MC落入非变动星座 8
        $mcInSigns = [0, 0, 1, 0, 2, 3, 1, 4, 5, 2, 6, 7, 3];

        $planetMcInChangeSignStatus = $planets[MC]['in_sign_id'] % 3 === 0 ? 1 : 0;
        if ($planetMcInChangeSignStatus)
        {
            $tags[] = 120106010100 + $mcInSigns[$planets[MC]['in_sign_id']];
        } else
        {
            $tags[] = 120106010000 + $mcInSigns[$planets[MC]['in_sign_id']];
        }
        // 月亮或者天王星、冥王星落入第十宫  6
        if ($planets[1]['in_house_id'] === 10)
        {
            $tags[] = 1201060200;
        }
        if ($planets[7]['in_house_id'] === 10)
        {
            $tags[] = 1201060201;
        }
        if ($planets[9]['in_house_id'] === 10)
        {
            $tags[] = 1201060202;
        }
        // 月亮或者天王星、冥王星落入第六宫 6
        if ($planets[1]['in_house_id'] === 6)
        {
            $tags[] = 1201060300;
        }
        if ($planets[7]['in_house_id'] === 6)
        {
            $tags[] = 1201060301;
        }
        if ($planets[9]['in_house_id'] === 6)
        {
            $tags[] = 1201060302;
        }
        // 土星落入第十宫、第六宫 2
        if ($planets[6]['in_house_id'] === 10)
        {
            $tags[] = 1201060401;
        } elseif ($planets[6]['in_house_id'] === 6)
        {
            $tags[] = 1201060400;
        }

        $result = [
            'desc' => '主题 2：你天生的职业倾向与类别',
            'content_list' => $tags,
            'levels' => []
        ];
        return $result;
    }

    /**
     * 事业报告 主题 3：你是否适合创业？或者平凡就业工作？
     */
    protected function getCarrerReportSection3(): array
    {
        $planets = $this->astroData['planets'];
        $levels = $tags = [];
        //①判断你是否【适合创业】？
        //——描述【适合创业的原因】（300 字）；
        //1、判断是否角宫行星强调，10个行星，有5个行星落入角宫，判断为适合创业。
        //2、判断是否本位星座强调，超过5个为强势，判断为适合创业。
        //3、判断东边行星是否多，超过7个，为强势，判断为适合创业。
        $planetsInAngularHouseNum = 0;// 行星在角宫的数量
        $planetsInChangeHouseNum = 0;// 行星在变动宫的数量
        $planetsInBaseSignNum = 0;// 行星在本位星座的数量
        $planetsInFixedSignNum = 0;// 行星在固定星座的数量
        $planetsAtEastLocationNum = 0;// 行星在东边的数量
        for ($i = 0; $i < 10; $i++)
        {
            // 落入角宫
            if ($planets[$i]['in_house_id'] % 3 === 1)
            {
                $planetsInAngularHouseNum++;
            } elseif ($planets[$i]['in_house_id'] % 3 === 0)
            {
                $planetsInChangeHouseNum++;
            }
            // 落入本位星座
            if ($planets[$i]['in_sign_id'] % 3 === 1)
            {
                $planetsInBaseSignNum++;
            } elseif ($planets[$i]['in_sign_id'] % 3 === 2)
            {
                $planetsInFixedSignNum++;
            }
            // 行星在星盘的东边
            if ($planets[$i]['in_house_id'] <= 3 || $planets[$i]['in_house_id'] >= 10)
            {
                $planetsAtEastLocationNum++;
            }
        }
        // 行星是否在角宫数量多
        $planetsInAngularHouseNumStatus = $planetsInAngularHouseNum >= 5 ? 1 : 0;
        // 行星是否在本位星座数量多
        $planetsInBaseSignNumStatus = $planetsInBaseSignNum > 5 ? 1 : 0;
        // 行星是否在东边数量多
        $planetsAtEastLocationNumStatus = $planetsAtEastLocationNum > 7 ? 1 : 0;
        $hps = [];
        // 计算古典七星的先天得分
        for ($i = 0; $i < 7; $i++)
        {
            $hps[] = [
                'id' => $i,
                'power' => $planets[$i]['ancient']['power']
            ];
        }
        // 倒序排序
        $hps = resort($hps, 'power', 'DESC');
        //——描述创业过程出现的①顺利，有什么收获（400 字）+影响星级（图，需要逻辑算法）；
        // 先天得分前两位的，行星对创业正面有利影响7*200字
        //逻辑：两个行星先天得分和
        //>15分，为5分
        //>11分，4分
        //>7分，3分
        //>3分，2分
        //<3分,1分
        $theTopTwo = $hps[0]['power'] + $hps[1]['power'];
        if ($theTopTwo > 15)
        {
            $state1 = 0;
            $levels[] = 5;
        } elseif ($theTopTwo > 11)
        {
            $state1 = 1;
            $levels[] = 4;
        } elseif ($theTopTwo > 7)
        {
            $state1 = 2;
            $levels[] = 3;
        } elseif ($theTopTwo > 3)
        {
            $state1 = 3;
            $levels[] = 2;
        } else
        {
            $state1 = 4;
            $levels[] = 1;
        }
        //②困难或阻碍问题（400 字）+影响星级（图，需要逻辑算法）
        // 先天得分后两位的，行星对创业负面的影响7*200字
        //<-10分，为5分，
        //<-6分，4分
        //<-2分，3分
        //<0分，2分
        //>0分,1分
        $theBottomTwo = $hps[5]['power'] + $hps[6]['power'];
        if ($theBottomTwo < -10)
        {
            $state2 = 4;
            $levels[] = 5;
        } elseif ($theBottomTwo < -6)
        {
            $state2 = 3;
            $levels[] = 4;
        } elseif ($theBottomTwo < -2)
        {
            $state2 = 2;
            $levels[] = 3;
        } elseif ($theBottomTwo < 0)
        {
            $state2 = 1;
            $levels[] = 2;
        } else
        {
            $state2 = 0;
            $levels[] = 1;
        }

        // 符合一条为适合创业，
        if ($planetsInAngularHouseNumStatus
            || $planetsInAngularHouseNumStatus
            || $planetsAtEastLocationNumStatus)
        {
            // 角宫强调300字
            if ($planetsInAngularHouseNumStatus)
            {
                $tags[] = 1202000000;
            }// 本位强调300字
            elseif ($planetsInBaseSignNumStatus)
            {
                $tags[] = 1202000001;
            }// 东边行星强调
            elseif ($planetsAtEastLocationNumStatus)
            {
                $tags[] = 1202000002;
            }
            $tags[] = 120200010000 + $hps[0]['id'] * 100 + $state1;
            $tags[] = 120200010000 + $hps[1]['id'] * 100 + $state1;
            $tags[] = 120200020000 + $hps[6]['id'] * 100 + $state1;
            $tags[] = 120200020000 + $hps[5]['id'] * 100 + $state1;
        } else
        {
            // 变动宫强调
            if ($planetsInChangeHouseNum >= 5)
            {
                $tags[] = 1202000300;
            }// 固定强调
            elseif ($planetsInFixedSignNum >= 5)
            {
                $tags[] = 1202000301;
            }// 西边行星强调
            elseif (!$planetsAtEastLocationNumStatus)
            {
                $tags[] = 1202000302;
            }
            $tags[] = 120200040000 + $hps[0]['id'] * 100 + $state2;
            $tags[] = 120200040000 + $hps[1]['id'] * 100 + $state2;
            $tags[] = 120200050000 + $hps[6]['id'] * 100 + $state2;
            $tags[] = 120200050000 + $hps[5]['id'] * 100 + $state2;
        }

        $result = [
            'desc' => '主题 3：你是否适合创业？或者平凡就业工作？',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 事业报告 主题 4：你是否适合合伙的经营事业？
     */
    protected function getCarrerReportSection4(): array
    {
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        $tags = $levels = [];
        //判断你是否【适合合伙经营事业】？
        // 第七宫宫主星，先天得分大于3分为适合合伙。
        $house7ProtectAncientPower = $planets[$houses[7]['protect_ancient_id']]['ancient']['power'];
        // 第八宫宫主星，先天得分大于3分为适合合伙。
        $house8ProtectAncientPower = $planets[$houses[8]['protect_ancient_id']]['ancient']['power'];
        // 福点落宫
        $fortInHouse = $planets[14]['in_house_id'];
        if ($house7ProtectAncientPower > 3 || $house8ProtectAncientPower > 3 || in_array($fortInHouse, [7, 8], true))
        {
            $suitableStatus = 1;
        } else
        {
            $suitableStatus = 0;
        }

        $suitablePower = ($house7ProtectAncientPower + $house8ProtectAncientPower) / 2;
        // 适合
        if ($suitableStatus)
        {
            //——描述适合合伙经营事业的【原因】及【收获】（300 字）+影响星级（图，需要逻辑算法）；
            //（第七宫宫主星+第八宫宫主星）/2，先天得分>7,>5,>3,>2,>1,5个档次。
            $level = 1;
            if ($suitablePower > 7)
            {
                $level = 5;
            } elseif ($suitablePower > 5)
            {
                $level = 4;
            } elseif ($suitablePower > 3)
            {
                $level = 3;
            } elseif ($suitablePower > 2)
            {
                $level = 2;
            }
            // 第七宫宫主星落入宫位12种，收获150*12*7
            $tags[] = 1203000200 + $houses[7]['protect_ancient_inhouse_id'] - 1;
            // 第七宫宫主星落入星座
            $tags[] = 1203000100 + $houses[7]['protect_ancient_insign_id'] - 1;
            // 第八宫宫主星落入宫位
            $tags[] = 1203000300 + $houses[8]['protect_ancient_inhouse_id'] - 1;
            if ($fortInHouse === 7)
            {
                $tags[] = 1203000000;
            } elseif ($fortInHouse === 8)
            {
                $tags[] = 1203000001;
            }
        }// 不适合
        else
        {
            //——描述不适合合伙经营事业的【原因】及【困难或阻碍问题】（300 字）+影响星级（图，需要逻辑算法）；
            // 第七宫宫主星落入宫位12种，收获150*12*7
            $tags[] = 1203010100 + $houses[7]['protect_ancient_inhouse_id'] - 1;
            // 第七宫宫主星落入星座
            $tags[] = 1203010000 + $houses[7]['protect_ancient_insign_id'] - 1;
            // 第八宫宫主星落入宫位
            $tags[] = 1203010200 + $houses[8]['protect_ancient_inhouse_id'] - 1;
            // （第七宫宫主星+第八宫宫主星）/2，先天得分<-10,<-6,<-2,<0,其他,5个档次。
            $level = 1;
            if ($suitablePower < -10)
            {
                $level = 5;
            } elseif ($suitablePower < -6)
            {
                $level = 4;
            } elseif ($suitablePower < -2)
            {
                $level = 3;
            } elseif ($suitablePower < 0)
            {
                $level = 2;
            }
        }
        // 影响星级
        $levels[] = $level;

        $result = [
            'desc' => '主题 4：你是否适合合伙的经营事业？',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 事业报告 主题 5：你的事业升迁机遇如何？或者事业经营能否成功？
     */
    protected function getCarrerReportSection5(): array
    {
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        //①你能否在工作或事业中拥有尊严、成就？
        //——描述你在工作事业中能否获得好的【尊严】、【成就】、以及【升迁机遇】（300 字）+影响星级（图，需要逻辑算法）；
        // 7个行星成就分成五个档次描述，和尊严
        //②若是获得成功，你的成功能否持续？
        //——描述你在工作事业中，成功能否延续的分析（200 字）
        // 太阳-土星每个行星单独写，2个等级
        $tags = $levels = [];
        // 1、第十宫宫主星尊贵得分，超过0分为能够获得成就
        $house10ProtectAncient = $houses[10]['protect_ancient_id'];
        $house10ProtectAncientPower = $planets[$house10ProtectAncient]['ancient']['power'];
        // 2、得分>0,>3分，>5分，>7,>9分，分5个档位，调用语料7*5*300
        if ($house10ProtectAncientPower > 9)
        {
            $state = 5;
        } elseif ($house10ProtectAncientPower > 7)
        {
            $state = 4;
        } elseif ($house10ProtectAncientPower > 5)
        {
            $state = 3;
        } elseif ($house10ProtectAncientPower > 3)
        {
            $state = 2;
        } else
        {
            // 不适合的统一到最低档
            $state = 1;
        }
        $tags[] = 120400000000 + $house10ProtectAncient * 100 + $state - 1;
        $levels[] = $state;
        // 获取10宫主的三分主星
        $house10ProtectAncientTrisectionPlanets = $planets[$house10ProtectAncient]['ancient']['or_trisection_planet_id'];

        $types = [[5, 4, 3], [2, 1, 0]];
        $lv = 0;
        foreach ($house10ProtectAncientTrisectionPlanets as $k => $p)
        {
            // 10宫主三分主星落宫(角、续、果) 角=>1，续=>2，果=>0
            $pInHouseType = $planets[$p]['in_house_id'] % 3;
            // 正分 负分
            $pPowerType = $planets[$p]['ancient']['power'] >= 0 ? 1 : 0;
            $tags[] = 120401000000 + $k * 10000 + $p * 100 + $types[$pPowerType][$pInHouseType];
            // 前中后得分相加用以计算星级🌟
            $lv += 5 - $types[$pPowerType][$pInHouseType];
        }
        //超过12分=5
        //超过9分=4
        //超过6分=3
        //超过4分=2
        //其余=1
        if ($lv > 12)
        {
            $levels[] = 5;
        } elseif ($lv > 9)
        {
            $levels[] = 4;
        } elseif ($lv > 6)
        {
            $levels[] = 3;
        } elseif ($lv > 4)
        {
            $levels[] = 2;
        } else
        {
            $levels[] = 1;
        }

        $result = [
            'desc' => '主题 5：你的事业升迁机遇如何？或者事业经营能否成功？',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 元素逻辑
     * @param array $astroData
     * @param array $result
     * @param int $index 当前排序到的索引 默认为1
     * @return array 四元素排序数组
     */
    protected function fixedPhase($astroData = [], &$result = [], $index = 1)
    {
        // 初始化排序
        if (empty($result))
        {
            $result = [];
            // 逻辑：元素排序，选择10个行星
            //工作正面负面影响，这个解释放在行星相位前面。
            $element = [
                ['type' => 0, 'num' => 0, 'power' => 0],
                ['type' => 1, 'num' => 0, 'power' => 0],
                ['type' => 2, 'num' => 0, 'power' => 0],
                ['type' => 3, 'num' => 0, 'power' => 0]
            ];// 元素 0水、1火、2土、3风
            for ($i = 0; $i < 10; $i++)
            {
                $planetIInSignType = $astroData['planets'][$i]['in_sign_id'] % 4;// 计算行星落座元素
                $element[$planetIInSignType]['num']++;// 四元素中的行星数量+1
                $element[$planetIInSignType]['power'] += $astroData['planets'][$i]['ancient']['power'];// 储存行星先天得分总和
            }
            // 根据数量进行排序
            $result = resort($element, 'num', 'DESC');
        } else
        {
            // 四元素排序完毕，返回数据
            if ($index > 3)
            {
                return $result;
            }
        }
        $preIndex = $index - 1;
        // 1、如果遇到相同，增加四轴再次比较。
        if ($result[$index]['num'] === $result[$preIndex]['num'])
        {
            $ascInSignType = $astroData['planets'][ASC]['in_sign_id'] % 4;
            $icInSignType = $astroData['planets'][IC]['in_sign_id'] % 4;
            $desInSignType = $astroData['planets'][DES]['in_sign_id'] % 4;
            $mcInSignType = $astroData['planets'][MC]['in_sign_id'] % 4;
            foreach ($result as $k => $e)
            {
                if ($e['type'] === $ascInSignType)
                {
                    $result[$k]['num']++;
                }
                if ($e['type'] === $icInSignType)
                {
                    $result[$k]['num']++;
                }
                if ($e['type'] === $desInSignType)
                {
                    $result[$k]['num']++;
                }
                if ($e['type'] === $mcInSignType)
                {
                    $result[$k]['num']++;
                }
            }
            // 再次进行排序
            $result = resort($result, 'num', 'DESC');
            // 2、还有相同，首先选择日月所在元素。
            if ($result[0]['num'] === $result[1]['num'])
            {
                $sunInSignType = $astroData['planets'][0]['in_sign_id'] % 4;
                $moonInSignType = $astroData['planets'][1]['in_sign_id'] % 4;
                // 3、还相同，选择元素行星先天得分相加排序。
                if ($sunInSignType !== $moonInSignType
                    && (($sunInSignType === $result[0]['type'] && $moonInSignType === $result[1]['type'])
                        || ($sunInSignType === $result[1]['type'] && $moonInSignType === $result[0]['type'])))
                {
                    $result = resort($element, 'power', 'DESC');
                    // 4、还相同，按照从水星到土星排序，比如前三步还相同，水星落火象，金星落风象，火星落水象，木星落土象，元素排序就是火>风>水>土。
                    if ($result[0]['power'] === $result[1]['power'])
                    {
                        // 按照从水星到土星排序
                        $mercInSignType = $astroData['planets'][2]['in_sign_id'] % 4;
                        $venuInSignType = $astroData['planets'][3]['in_sign_id'] % 4;
                        $marsInSignType = $astroData['planets'][4]['in_sign_id'] % 4;
                        $jupiInSignType = $astroData['planets'][5]['in_sign_id'] % 4;
                        $satuInSignType = $astroData['planets'][6]['in_sign_id'] % 4;

                        if (!in_array($mercInSignType, $result, true))
                        {
                            $result[] = $mercInSignType;
                        }
                        if (!in_array($venuInSignType, $result, true))
                        {
                            $result[] = $venuInSignType;
                        }
                        if (!in_array($marsInSignType, $result, true))
                        {
                            $result[] = $marsInSignType;
                        }
                        if (!in_array($jupiInSignType, $result, true))
                        {
                            $result[] = $jupiInSignType;
                        }
                        if (!in_array($satuInSignType, $result, true))
                        {
                            $result[] = $satuInSignType;
                        }
                        $resultCount = count($result);
                        if ($resultCount < 4)
                        {
                            for ($i = 0; $i < 4; $i++)
                            {
                                if (!in_array($i, $result, true))
                                {
                                    $result[] = $i;
                                }
                            }
                        }
                    } else
                    {
                        $result = [$result[0]['type'], $result[1]['type'], $result[2]['type'], $result[3]['type']];
                    }
                } else
                {
                    // 首先选择日月所在元素
                    if ($result[0]['type'] === $sunInSignType || $result[1]['type'] === $sunInSignType)
                    {
                        $result[] = $sunInSignType;
                    }
                    if ($result[0]['type'] === $moonInSignType || $result[1]['type'] === $moonInSignType)
                    {
                        $result[] = $moonInSignType;
                    }
                    foreach ($result as $esd)
                    {
                        if (!in_array($esd['type'], $result, true))
                        {
                            $result[] = $esd['type'];
                        }
                    }
                }
            } else
            {
                $result = [$result[0]['type'], $result[1]['type'], $result[2]['type'], $result[3]['type']];
            }
        } else
        {
            $result = [$result[0]['type'], $result[1]['type'], $result[2]['type'], $result[3]['type']];
        }

    }

    /**
     * 学业报告 主题 1：（曲线图）适合学习的年份
     */
    protected function getAcademicCurveData(): array
    {
        $levels = [];
        $y = 6;// 报告从6岁开始计算
        foreach ($this->firdariaData as $k => $firdaria)
        {
            // 1.按年纪默认得分8岁之前8分，18—24岁7分，24—30加6分，50岁后2分，60岁后0分。其他时间段默认取平均分5分。
            if ($y < 8)
            {
                $p = 8;
            } elseif ($y < 18)
            {
                $p = 5;
            } elseif ($y < 24)
            {
                $p = 7;
            } elseif ($y < 30)
            {
                $p = 6;
            } elseif ($y < 50)
            {
                $p = 5;
            } elseif ($y < 60)
            {
                $p = 2;
            } else
            {
                $p = 0;
            }
            $sub = $firdaria['firdaria']['sub_luck'];
            $p2 = $firdaria['planets'][$sub]['ancient']['power'];

            // 2.法达副运，1水星，木星主宰年份加先天超过5分加5分，超过0分加3分。
            if ($sub === 2 || $sub === 5)
            {
                if ($p2 > 5)
                {
                    $p += 5;
                } elseif ($p2 > 0)
                {
                    $p += 3;
                }
            }
            // 3.第三宫，第九宫主宰星年份，先天超过5分加5分，超过0分加三分。
            if ($firdaria['houses'][3]['protect_ancient_id'] === $sub
                || $firdaria['houses'][9]['protect_ancient_id'] === $sub)
            {
                if ($p2 > 5)
                {
                    $p += 5;
                } elseif ($p2 > 0)
                {
                    $p += 3;
                }
            }
            // 4.火星，土星年份，先天低于-5分，减5分，低于0分减3分。
            if (in_array($sub, [4, 6], true))
            {
                if ($p2 < -5)
                {
                    $p -= 5;
                } elseif ($p2 < 0)
                {
                    $p -= 3;
                }
            }

            $levels[] = $p;
            // 年龄+1
            $y++;
        }

        return [
            'desc' => '主题 1：（曲线图）适合学习的年份',
            'content_list' => [],
            'levels' => $levels
        ];
    }

    /**
     * 学业报告 主题 2：学业禀赋类型
     */
    protected function getAcademicReportSection1(): array
    {
        $tags = $levels = [];
        // 太阳到冥王十个行星+上升，中天，北交点，太阳月亮上升计算2分，其余1分。
        $base = [
            ['pid' => 0, 'score' => 2], ['pid' => 1, 'score' => 2], ['pid' => 2, 'score' => 1], ['pid' => 3, 'score' => 1], ['pid' => 4, 'score' => 1],
            ['pid' => 5, 'score' => 1], ['pid' => 6, 'score' => 1], ['pid' => 7, 'score' => 1], ['pid' => 8, 'score' => 1], ['pid' => 9, 'score' => 1],
            ['pid' => 12, 'score' => 1], ['pid' => 17, 'score' => 2], ['pid' => 20, 'score' => 1]
        ];
        // 选择最强的1个，如果得分相同，按照元素内行星先天尊贵加和，仍然相同，由太阳到冥王顺序优选最前面行星所在的那个元素。最后将所有元素排序。排出最强元素。
        $planets = $this->astroData['planets'];
        // 定义四元素数组：0=>包含的星体，1=>星体得分相加
        $es = [
            ['type' => 0, 'planets' => [], 'scores' => 0, 'powers' => 0],// 水
            ['type' => 1, 'planets' => [], 'scores' => 0, 'powers' => 0],// 火
            ['type' => 2, 'planets' => [], 'scores' => 0, 'powers' => 0],// 土
            ['type' => 3, 'planets' => [], 'scores' => 0, 'powers' => 0]// 风
        ];
        foreach ($base as $b)
        {
            // 行星落座
            $inSign = $planets[$b['pid']]['in_sign_id'];
            // 计算行星落入星座的元素属性
            $e = $inSign % 4;
            // 将落入该元素星座的行星加入
            $es[$e]['planets'][] = $b['pid'];
            // 元素得分
            $es[$e]['scores'] += $b['score'];
            // 元素内行星先天尊贵得分和
            $es[$e]['powers'] += $planets[$b['pid']]['ancient']['power'];
        }
        $es = resort($es, 'scores', 'DESC');

        $esByScores = [];
        // 按scores得分进行分组
        foreach ($es as $s)
        {
            $esByScores[$s['scores']][] = $s;
        }
        // 四元素得分有相同，需要进行二次排序
        if (count($esByScores) < 4)
        {
            foreach ($esByScores as $esbs)
            {
                // 该得分组下，有得分相同的
                if (count($esbs) > 1)
                {
                    foreach ($esbs as $k1 => $d1)
                    {
                        foreach ($esbs as $k2 => $d2)
                        {
                            if ($k1 < $k2)
                            {
                                /**
                                 * 第二次排序按照元素内行星先天尊贵得分和 进行排序
                                 * 若先天尊贵得分和一致，由太阳到冥王顺序优选最前面行星所在的那个元素
                                 */
                                if ($esbs[$k1]['powers'] < $esbs[$k2]['powers'] || ($esbs[$k1]['powers'] === $esbs[$k2]['powers'] && $esbs[$k1]['planets'][0] > $esbs[$k2]['planets'][0]))
                                {
                                    $esTmp = $esbs[$k1];
                                    $esbs[$k1] = $esbs[$k2];
                                    $esbs[$k2] = $esTmp;
                                }
                            }
                        }
                    }
                }
            }
            $sortEs = [];
            foreach ($esByScores as $d3)
            {
                foreach ($d3 as $d4)
                {
                    $sortEs[] = $d4;
                }
            }
        } else
        {
            $sortEs = $es;
        }

        $elementKey = [3, 0, 1, 2];// 1火2土3风0水
        $tags[] = 130100 + $elementKey[$sortEs[0]['type']];
        $result = [
            'desc' => '主题 2：学业禀赋类型',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 学业报告 主题 3：学习能力优劣势
     */
    protected function getAcademicReportSection2(): array
    {
        $tags = $levels = [];
        $elementKey = [3, 0, 1, 2];// 1火2土3风0水
        $planets = $this->astroData['planets'];
        // 太阳到冥王十个行星+上升，中天，北交点，太阳月亮上升计算2分，其余1分。
        $base = [
            ['pid' => 0, 'score' => 2], ['pid' => 1, 'score' => 2], ['pid' => 2, 'score' => 1], ['pid' => 3, 'score' => 1], ['pid' => 4, 'score' => 1],
            ['pid' => 5, 'score' => 1], ['pid' => 6, 'score' => 1], ['pid' => 7, 'score' => 1], ['pid' => 8, 'score' => 1], ['pid' => 9, 'score' => 1],
            ['pid' => 12, 'score' => 1], ['pid' => 17, 'score' => 2], ['pid' => 20, 'score' => 1]
        ];
        // 选择最强的1个，如果得分相同，按照元素内行星先天尊贵加和，仍然相同，由太阳到冥王顺序优选最前面行星所在的那个元素。最后将所有元素排序。排出最强元素。
        // 定义四元素数组：0=>包含的星体，1=>星体得分相加
        $es = [
            ['type' => 0, 'planets' => [], 'scores' => 0, 'powers' => 0],// 水
            ['type' => 1, 'planets' => [], 'scores' => 0, 'powers' => 0],// 火
            ['type' => 2, 'planets' => [], 'scores' => 0, 'powers' => 0],// 土
            ['type' => 3, 'planets' => [], 'scores' => 0, 'powers' => 0]// 风
        ];
        foreach ($base as $b)
        {
            // 行星落座
            $inSign = $planets[$b['pid']]['in_sign_id'];
            // 计算行星落入星座的元素属性
            $e = $inSign % 4;
            // 将落入该元素星座的行星加入
            $es[$e]['planets'][] = $b['pid'];
            // 元素得分
            $es[$e]['scores'] += $b['score'];
            // 元素内行星先天尊贵得分和
            $es[$e]['powers'] += $planets[$b['pid']]['ancient']['power'];
        }
        $es = resort($es, 'scores', 'DESC');

        $esByScores = [];
        // 按scores得分进行分组
        foreach ($es as $s)
        {
            $esByScores[$s['scores']][] = $s;
        }
        // 四元素得分有相同，需要进行二次排序
        if (count($esByScores) < 4)
        {
            foreach ($esByScores as $esbs)
            {
                // 该得分组下，有得分相同的
                if (count($esbs) > 1)
                {
                    foreach ($esbs as $k1 => $d1)
                    {
                        foreach ($esbs as $k2 => $d2)
                        {
                            if ($k1 < $k2)
                            {
                                /**
                                 * 第二次排序按照元素内行星先天尊贵得分和 进行排序
                                 * 若先天尊贵得分和一致，由太阳到冥王顺序优选最前面行星所在的那个元素
                                 */
                                if ($esbs[$k1]['powers'] < $esbs[$k2]['powers'] || ($esbs[$k1]['powers'] === $esbs[$k2]['powers'] && $esbs[$k1]['planets'][0] > $esbs[$k2]['planets'][0]))
                                {
                                    $esTmp = $esbs[$k1];
                                    $esbs[$k1] = $esbs[$k2];
                                    $esbs[$k2] = $esTmp;
                                }
                            }
                        }
                    }
                }
            }
            $sortEs = [];
            foreach ($esByScores as $d3)
            {
                foreach ($d3 as $d4)
                {
                    $sortEs[] = $d4;
                }
            }
        } else
        {
            $sortEs = $es;
        }
        if ($sortEs[0]['scores'] >= 5)
        {
            $goodStatus = 5;
        } elseif ($sortEs[0]['scores'] >= 4)
        {
            $goodStatus = 4;
        } elseif ($sortEs[0]['scores'] >= 3)
        {
            $goodStatus = 3;
        } elseif ($sortEs[0]['scores'] >= 2)
        {
            $goodStatus = 2;
        } else
        {
            $goodStatus = 1;
        }

        if ($sortEs[3]['scores'] >= 5)
        {
            $badStatus = 5;
        } elseif ($sortEs[3]['scores'] >= 4)
        {
            $badStatus = 4;
        } elseif ($sortEs[3]['scores'] >= 3)
        {
            $badStatus = 3;
        } elseif ($sortEs[3]['scores'] >= 2)
        {
            $badStatus = 2;
        } else
        {
            $badStatus = 1;
        }
        $levels = [$goodStatus, $badStatus, $badStatus];

        // 优势词条
        $tags[] = 1302000000 + $elementKey[$sortEs[0]['type']] * 10000 + ($goodStatus - 1) * 100;
        // 劣势及建议词条
        $tags[] = 1302000001 + $elementKey[$sortEs[3]['type']] * 10000 + ($badStatus - 1) * 100;
        $tags[] = 1302000002 + $elementKey[$sortEs[3]['type']] * 10000 + ($badStatus - 1) * 100;

        $levels['radar'] = [
            ['a' => $sortEs[0]['type'], 's' => $sortEs[0]['scores']],
            ['a' => $sortEs[1]['type'], 's' => $sortEs[1]['scores']],
            ['a' => $sortEs[2]['type'], 's' => $sortEs[2]['scores']],
            ['a' => $sortEs[3]['type'], 's' => $sortEs[3]['scores']],
        ];

        $result = [
            'desc' => '主题 3：学习能力优劣势',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 学业报告 主题4：适合你学习科目及专业
     */
    protected function getAcademicReportSection3(): array
    {
        $tags = [];
        $levels = [0 => 0, 1 => 0, 'radar' => [0 => [], 1 => []]];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];

        //——征象星取用
        /**
         * type=0 文科
         * type=1 理科
         * type=2 艺术
         * type=3 体育
         */
        $subjects = [
            ['type' => 0, 'score' => 0, 'planetsPowers' => []],
            ['type' => 1, 'score' => 0, 'planetsPowers' => []],
            ['type' => 2, 'score' => 0, 'planetsPowers' => []],
            ['type' => 3, 'score' => 0, 'planetsPowers' => []]
        ];
        $house1ProtectAncient = $houses[1]['protect_ancient_id'];
        $house3ProtectAncient = $houses[3]['protect_ancient_id'];

        $powers = [];
        $ps = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
        foreach ($ps as $p)
        {
            $tp = $planets[$p]['ancient']['power'];
            if ($planets[$p]['ancient']['migration'] !== -1)
            {
                $tp += 5;
            }
            $powers[] = $tp;
        }
        //①计算1、3宫主星、水星、月亮的尊贵禀赋（游走计 0 分）
        /**
         * type=0 3宫主
         * type=1 水星
         * type=2 月亮
         * type=3 1宫主
         */
        $planetsPower = [
            ['type' => 0, 'id' => $house3ProtectAncient, 'power' => $powers[$house3ProtectAncient]],
            ['type' => 1, 'id' => 2, 'power' => $powers[2]],
            ['type' => 2, 'id' => 1, 'power' => $powers[1]],
            ['type' => 3, 'id' => $house1ProtectAncient, 'power' => $powers[$house1ProtectAncient]],
        ];
        //②做以上数值的依次排序，若有相同分数，则以 3R＞水星＞月亮＞1R 排序
        foreach ($planetsPower as $k1 => $plp1)
        {
            foreach ($planetsPower as $k2 => $plp2)
            {
                if ($k1 < $k2)
                {
                    if ($planetsPower[$k1]['power'] < $planetsPower[$k2]['power']
                        || ($planetsPower[$k1]['power'] === $planetsPower[$k2]['power']
                            && $planetsPower[$k1]['type'] > $planetsPower[$k2]['type']))
                    {
                        $temp = $planetsPower[$k1];
                        $planetsPower[$k1] = $planetsPower[$k2];
                        $planetsPower[$k2] = $temp;
                    }
                }
            }
        }
        //取用排序第一的为科目征象星
        $symptomPlanet = $planetsPower[0]['id'];
        //——科目取用
        //③观察征象星的相位和接纳互容的星体
        $subjectSymptomStatus = [false, false, false];
        // 水星、月亮、金星、木星，文科+1
        if (in_array($symptomPlanet, [1, 2, 3, 5], true))
        {
            $subjects[0]['score']++;
            $subjectSymptomStatus[0] = true;
        }
        // 当征象星为：水星、火星、土星，理科+1
        if (in_array($symptomPlanet, [2, 4, 6], true))
        {
            $subjects[1]['score']++;
            $subjectSymptomStatus[1] = true;
        }
        // 当征象星为：太阳、金星，艺术+1
        if (in_array($symptomPlanet, [0, 3], true))
        {
            $subjects[2]['score']++;
            $subjectSymptomStatus[2] = true;
        }
        // 当征象星有相位
        if (!empty($planets[$symptomPlanet]['phase']))
        {
            foreach ($planets[$symptomPlanet]['phase'] as $phase)
            {
                switch ($phase['phase_e'])
                {
                    // 0˚
                    case 0:
                        switch ($phase['id'])
                        {
                            case 1:
                            case 5:
                                $subjects[0]['score'] += 5;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 2:
                                $subjects[0]['score'] += 5;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                $subjects[1]['score'] += 5;
                                $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 3:
                                $subjects[0]['score'] += 5;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                $subjects[2]['score'] += 5;
                                $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 4:
                            case 6:
                            case 7:
                                $subjects[1]['score'] += 5;
                                $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 8:
                                $subjects[2]['score'] += 5;
                                $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            default:
                                break;
                        }
                        break;
                    // 60˚/120˚
                    case 60:
                    case 120:
                        switch ($phase['id'])
                        {
                            case 1:
                            case 5:
                                $subjects[0]['score'] += 2;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 2:
                                $subjects[0]['score'] += 2;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                $subjects[1]['score'] += 2;
                                $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 3:
                                $subjects[0]['score'] += 2;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                $subjects[2]['score'] += 2;
                                $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 4:
                            case 6:
                            case 7:
                                $subjects[1]['score'] += 2;
                                $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 8:
                                $subjects[2]['score'] += 2;
                                $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            default:
                                break;
                        }
                        break;
                    // 90˚/180˚
                    case 90:
                    case 180:
                        switch ($phase['id'])
                        {
                            case 1:
                            case 5:
                                $subjects[0]['score']++;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 2:
                                $subjects[0]['score']++;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                $subjects[1]['score']++;
                                $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 3:
                                $subjects[0]['score']++;
                                $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                $subjects[2]['score'] += 5;
                                $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 4:
                            case 6:
                            case 7:
                                $subjects[1]['score']++;
                                $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            case 8:
                                $subjects[2]['score'] += 5;
                                $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
                                break;
                            default:
                                break;
                        }
                        break;
                    default:
                        break;
                }
//                // 当征象星，与水星、月亮、金星、木星有相位：
//                if ($subjectSymptomStatus[0] === true && in_array($phase['id'], [1, 2, 3, 5], true))
//                {
//                    // 0°，文科+5
//                    if ($phase['phase_e'] === 0)
//                    {
//                        $subjects[0]['score'] += 5;
//                        $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }// 60/120°，文科+2
//                    elseif (in_array($phase['phase_e'], [60, 120], true))
//                    {
//                        $subjects[0]['score'] += 2;
//                        $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }// 90/180°，文科+1
//                    elseif (in_array($phase['phase_e'], [90, 180], true))
//                    {
//                        $subjects[0]['score']++;
//                        $subjects[0]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }
//                }
//                // 当征象星，与水星、火星、土星、天王有相位：
//                if ($subjectSymptomStatus[1] === true && in_array($phase['id'], [2, 4, 6, 7], true))
//                {
//                    // 0°，理科+5，
//                    if ($phase['phase_e'] === 0)
//                    {
//                        $subjects[1]['score'] += 5;
//                        $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }// 60/120°，理科+2，
//                    elseif (in_array($phase['phase_e'], [60, 120], true))
//                    {
//                        $subjects[1]['score'] += 2;
//                        $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }// 90/180°，理科+1
//                    elseif (in_array($phase['phase_e'], [90, 180], true))
//                    {
//                        $subjects[1]['score']++;
//                        $subjects[1]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }
//                }
//                // 当征象星，与金星、海王有相位0/90/180，艺术+5 ; 60/120，艺术+2
//                if ($subjectSymptomStatus[2] === true && in_array($phase['id'], [3, 8], true))
//                {
//                    // 0/90/180°，艺术+5
//                    if (in_array($phase['phase_e'], [0, 90, 180], true))
//                    {
//                        $subjects[2]['score'] += 5;
//                        $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }// 60/120°，艺术+2
//                    elseif (in_array($phase['phase_e'], [60, 120], true))
//                    {
//                        $subjects[2]['score'] += 2;
//                        $subjects[2]['planetsPowers'][] = ['id' => $phase['id'], 'power' => $powers[$phase['id']]];
//                    }
//                }
            }
        }
        // 当征象星有接纳互容
        foreach ($this->astroData['characteristic'] as $t => $characteristic)
        {
            if ($t !== 1 && $t !== 2) break;
            foreach ($characteristic as $c)
            {
                /**
                 * 当征象星，与水星、月亮、金星、木星有【接纳：文科+3、互容：文科+5】
                 * 当征象星，与水星、火星、土星、天王有【接纳：理科+3、互容：理科+5】
                 * 当征象星，与太阳、金星有          【接纳：艺术+3、互容：艺术+5】
                 */
                if (($c['id1'] === $symptomPlanet && $c['id2'] === 0) || ($c['id1'] === 0 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，艺术+3，
                    if ($t === 1)
                    {
                        $subjects[2]['score'] += 3;
                        $subjects[2]['planetsPowers'][] = ['id' => 0, 'power' => $powers[0]];
                    }//互容，艺术+5
                    elseif ($t === 2)
                    {
                        $subjects[2]['score'] += 5;
                        $subjects[2]['planetsPowers'][] = ['id' => 0, 'power' => $powers[0]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 1) || ($c['id1'] === 1 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，文科+3，
                    if ($t === 1)
                    {
                        $subjects[0]['score'] += 3;
                        $subjects[0]['planetsPowers'][] = ['id' => 1, 'power' => $powers[1]];
                    }//互容，文科+5
                    elseif ($t === 2)
                    {
                        $subjects[0]['score'] += 5;
                        $subjects[0]['planetsPowers'][] = ['id' => 1, 'power' => $powers[1]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 2) || ($c['id1'] === 2 && $c['id2'] === $symptomPlanet))
                {
                    // 接纳，文科+3，理科+3，
                    if ($t === 1)
                    {
                        $subjects[0]['score'] += 3;
                        $subjects[0]['planetsPowers'][] = ['id' => 2, 'power' => $powers[2]];
                        $subjects[1]['score'] += 3;
                        $subjects[1]['planetsPowers'][] = ['id' => 2, 'power' => $powers[2]];
                    }// 互容，文科+5，理科+5
                    elseif ($t === 2)
                    {
                        $subjects[0]['score'] += 5;
                        $subjects[0]['planetsPowers'][] = ['id' => 2, 'power' => $powers[2]];
                        $subjects[1]['score'] += 5;
                        $subjects[1]['planetsPowers'][] = ['id' => 2, 'power' => $powers[2]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 3) || ($c['id1'] === 3 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，文科+3，艺术+3，
                    if ($t === 1)
                    {
                        $subjects[0]['score'] += 3;
                        $subjects[0]['planetsPowers'][] = ['id' => 3, 'power' => $powers[3]];
                        $subjects[2]['score'] += 3;
                        $subjects[2]['planetsPowers'][] = ['id' => 0, 'power' => $powers[0]];
                    }//互容，文科+5，艺术+5
                    elseif ($t === 2)
                    {
                        $subjects[0]['score'] += 5;
                        $subjects[0]['planetsPowers'][] = ['id' => 3, 'power' => $powers[3]];
                        $subjects[2]['score'] += 5;
                        $subjects[2]['planetsPowers'][] = ['id' => 0, 'power' => $powers[0]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 4) || ($c['id1'] === 4 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，理科+3，
                    if ($t === 1)
                    {
                        $subjects[1]['score'] += 3;
                        $subjects[1]['planetsPowers'][] = ['id' => 4, 'power' => $powers[4]];
                    }//互容，理科+5
                    elseif ($t === 2)
                    {
                        $subjects[1]['score'] += 5;
                        $subjects[1]['planetsPowers'][] = ['id' => 4, 'power' => $powers[4]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 5) || ($c['id1'] === 5 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，文科+3，
                    if ($t === 1)
                    {
                        $subjects[0]['score'] += 3;
                        $subjects[0]['planetsPowers'][] = ['id' => 5, 'power' => $powers[5]];
                    }//互容，文科+5
                    elseif ($t === 2)
                    {
                        $subjects[0]['score'] += 5;
                        $subjects[0]['planetsPowers'][] = ['id' => 5, 'power' => $powers[5]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 6) || ($c['id1'] === 6 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，理科+3，
                    if ($t === 1)
                    {
                        $subjects[1]['score'] += 3;
                        $subjects[1]['planetsPowers'][] = ['id' => 6, 'power' => $powers[6]];
                    }//互容，文科+5
                    elseif ($t === 2)
                    {
                        $subjects[1]['score'] += 5;
                        $subjects[1]['planetsPowers'][] = ['id' => 6, 'power' => $powers[6]];
                    }
                } elseif (($c['id1'] === $symptomPlanet && $c['id2'] === 7) || ($c['id1'] === 7 && $c['id2'] === $symptomPlanet))
                {
                    //接纳，理科+3，
                    if ($t === 1)
                    {
                        $subjects[1]['score'] += 3;
                        $subjects[1]['planetsPowers'][] = ['id' => 7, 'power' => $powers[7]];
                    }//互容，理科+5
                    elseif ($t === 2)
                    {
                        $subjects[1]['score'] += 5;
                        $subjects[1]['planetsPowers'][] = ['id' => 7, 'power' => $powers[7]];
                    }
                }
            }
        }

        //分别计算文理科、艺术分值，取最高值为科目
        $subjects = resort($subjects, 'score', 'DESC');
        //*若科目征象星空相、无任何接纳互容，则以征象星的文理分值判断为准
        //若科目征象星为水星，且空相、无任何接纳互容，则附加3R＞1R去重水星，增加科目比分，计算征象星科目最高分值

        //3、词条调用逻辑
        //取征象星+科目（与与征象星产生相位、互容接纳的最高分星体）
        //若无，则取征象星+科目词条
        /**
         * 【文科】0=>水星、1=>月亮、2=>金星、
         * 【理科】3=>水星、4=>土星、5=>天王星、
         * 【艺术】6=>金星、7=>海王星、
         * 【体育】8=>火星
         */
        if ($subjects[0]['score'] === 0)
        {
            // 若没有，则调用体育的词条
            $tags[] = 13030000 + 8;
        } else
        {
            $subject = $subjects[0]['type'];
            $scores1 = resort($subjects[0]['planetsPowers'], 'power', 'DESC');
            $scores2 = resort($subjects[1]['planetsPowers'], 'power', 'DESC');
            if ($subjects[0]['score'] === $subjects[1]['score'] && (empty($scores1) || (!empty($scores2) && $scores1[0]['power'] < $scores2[0]['power'])))
            {
                $subject = $subjects[1]['type'];
                $scores = resort($subjects[1]['planetsPowers'], 'power', 'DESC');
            } else
            {
                $scores = resort($subjects[0]['planetsPowers'], 'power', 'DESC');
            }
            $end = false;

            if (empty($scores))
            {
                // 若首位为3宫主，则调用1宫主
                if ($planetsPower[0]['id'] === $house3ProtectAncient)
                {
                    $symptomPlanet = $house1ProtectAncient;
                }// 否则调用3宫主
                else
                {
                    $symptomPlanet = $house3ProtectAncient;
                }
                // 当征象星为：水星、月亮、金星、木星，文科+1
                if (in_array($symptomPlanet, [1, 2, 3, 5], true))
                {
                    $subjects[0]['score']++;
                }
                // 当征象星为：水星、火星、土星，理科+1
                if (in_array($symptomPlanet, [2, 4, 6], true))
                {
                    $subjects[1]['score']++;
                }
                // 当征象星为：太阳、金星，艺术+1
                if (in_array($symptomPlanet, [0, 3], true))
                {
                    $subjects[2]['score']++;
                }
                $subjects = resort($subjects, 'score', 'DESC');
                $subject = $subjects[0]['type'];
                $scores = resort($subjects[0]['planetsPowers'], 'power', 'DESC');
                // 强行调海王星艺术
                if ($subjects[0]['score'] === $subjects[1]['score'])
                {
                    $end = true;
                    $tags[] = 13030000 + 7;
                }
            }
            if ($end === false)
            {
                switch ($subject)
                {
                    //文科
                    //水星 > 月亮 > 木星=>月亮 > 金星
                    case 0:
                        if (empty($scores))
                        {
                            switch ($symptomPlanet)
                            {
                                case 2:
                                    $tags[] = 13030000;
                                    break;
                                case 1:
                                case 5:
                                    $tags[] = 13030000 + 1;
                                    break;
                                default:
                                    $tags[] = 13030000 + 2;
                                    break;
                            }
                        } elseif ($powers[2] === $scores[0]['power'])
                        {
                            $tags[] = 13030000;
                        } elseif ($powers[1] === $scores[0]['power'] || $powers[5] === $scores[0]['power'])
                        {
                            $tags[] = 13030000 + 1;
                        } else
                        {
                            $tags[] = 13030000 + 2;
                        }
                        break;
                    //理科
                    //水星 > 土星 > 天王星 > 火星=>水星
                    case 1:
                        if (empty($scores))
                        {
                            switch ($symptomPlanet)
                            {
                                case 2:
                                    $tags[] = 13030000 + 3;
                                    break;
                                case 6:
                                    $tags[] = 13030000 + 4;
                                    break;
                                case 7:
                                    $tags[] = 13030000 + 5;
                                    break;
                                default:
                                    $tags[] = 13030000 + 3;
                                    break;
                            }
                        } elseif ($powers[2] === $scores[0]['power'])
                        {
                            $tags[] = 13030000 + 3;
                        } elseif ($powers[6] === $scores[0]['power'])
                        {
                            $tags[] = 13030000 + 4;
                        } elseif ($powers[7] === $scores[0]['power'])
                        {
                            $tags[] = 13030000 + 5;
                        } else
                        {
                            $tags[] = 13030000 + 3;
                        }
                        break;
                    //艺术
                    //太阳=>金星 > 金星 > 海王
                    case 2:
                        if (empty($scores))
                        {
                            switch ($symptomPlanet)
                            {
                                case 0:
                                case 3:
                                    $tags[] = 13030000 + 6;
                                    break;
                                default:
                                    $tags[] = 13030000 + 7;
                                    break;
                            }
                        } elseif ($powers[0] === $scores[0]['power'] || $powers[3] === $scores[0]['power'])
                        {
                            $tags[] = 13030000 + 6;
                        } else
                        {
                            $tags[] = 13030000 + 7;
                        }
                        break;
                    //体育
                    //火星
                    default:
                        $tags[] = 13030000 + 8;
                        break;
                }
            }
        }

        // ② 适合专业分析+影响星级（200 字）
        $houses = $this->astroData['houses'];
        $scores = [
            0 => ['id' => 0, 'score' => 0, 'num' => 0],
            1 => ['id' => 1, 'score' => 0, 'num' => 0],
            2 => ['id' => 2, 'score' => 0, 'num' => 0],
            3 => ['id' => 3, 'score' => 0, 'num' => 0],
            4 => ['id' => 4, 'score' => 0, 'num' => 0],
            5 => ['id' => 5, 'score' => 0, 'num' => 0],
            6 => ['id' => 6, 'score' => 0, 'num' => 0],
        ];
        // 1、雷达图逻辑（取数值最高的前 4个）
        //①计算1、3、9、11 宫主星、
        //  9和11宫三分主星、
        //  9和11宫宫内星的尊贵禀赋（游走计 0 分）
        $house1ProtectAncient = $houses[1]['protect_ancient_id'];
        $house3ProtectAncient = $houses[3]['protect_ancient_id'];
        $house9ProtectAncient = $houses[9]['protect_ancient_id'];
        $house11ProtectAncient = $houses[11]['protect_ancient_id'];
        $scores[$house1ProtectAncient]['num']++;
        $scores[$house1ProtectAncient]['score'] += $planets[$house1ProtectAncient]['ancient']['power'];
        if ($planets[$house1ProtectAncient]['ancient']['migration'] === 1)
        {
            $scores[$house1ProtectAncient]['score'] += 5;
        }
        $scores[$house3ProtectAncient]['num']++;
        $scores[$house3ProtectAncient]['score'] += $planets[$house3ProtectAncient]['ancient']['power'];
        if ($planets[$house3ProtectAncient]['ancient']['migration'] === 1)
        {
            $scores[$house3ProtectAncient]['score'] += 5;
        }
        $scores[$house9ProtectAncient]['num']++;
        $scores[$house9ProtectAncient]['score'] += $planets[$house9ProtectAncient]['ancient']['power'];
        if ($planets[$house9ProtectAncient]['ancient']['migration'] === 1)
        {
            $scores[$house9ProtectAncient]['score'] += 5;
        }
        $scores[$house11ProtectAncient]['num']++;
        $scores[$house11ProtectAncient]['score'] += $planets[$house11ProtectAncient]['ancient']['power'];
        if ($planets[$house11ProtectAncient]['ancient']['migration'] === 1)
        {
            $scores[$house11ProtectAncient]['score'] += 5;
        }
        // 古典参数配置
        $ancients = config('astrolog.ancient');
        // 9宫三分主星(宫头星座三分主)
        $house9DispositorTrisection = $ancients[$houses[9]['in_sign_id']][2];
        foreach ($house9DispositorTrisection as $h9dt)
        {
            $scores[$h9dt]['num']++;
            $scores[$h9dt]['score'] += $planets[$h9dt]['ancient']['power'];
            // 游走记0分
            if ($planets[$h9dt]['ancient']['migration'] === 1)
            {
                $scores[$h9dt]['score'] += 5;
            }
        }
        // 11宫三分主星(宫头星座三分主)
        $house11DispositorTrisection = $ancients[$houses[11]['in_sign_id']][2];
        foreach ($house11DispositorTrisection as $h11dt)
        {
            $scores[$h11dt]['num']++;
            $scores[$h11dt]['score'] += $planets[$h11dt]['ancient']['power'];
            // 游走记0分
            if ($planets[$h11dt]['ancient']['migration'] === 1)
            {
                $scores[$h11dt]['score'] += 5;
            }
        }
        // 9宫宫内星
        if (!empty($houses[9]['in_house_area_planet_info']))
        {
            foreach ($houses[9]['in_house_area_planet_info'] as $h9ihapi)
            {
                if ($h9ihapi['id'] < 7)
                {
                    $scores[$h9ihapi['id']]['num']++;
                    $scores[$h9ihapi['id']]['score'] += $planets[$h9ihapi['id']]['ancient']['power'];
                    // 游走记0分
                    if ($planets[$h9ihapi['id']]['ancient']['migration'] === 1)
                    {
                        $scores[$h9ihapi['id']]['score'] += 5;
                    }
                }
            }
        }
        // 11宫宫内星
        if (!empty($houses[11]['in_house_area_planet_info']))
        {
            foreach ($houses[11]['in_house_area_planet_info'] as $h11ihapi)
            {
                if ($h11ihapi['id'] < 7)
                {
                    $scores[$h11ihapi['id']]['num']++;
                    $scores[$h11ihapi['id']]['score'] += $planets[$h11ihapi['id']]['ancient']['power'];
                    // 游走记0分
                    if ($planets[$h11ihapi['id']]['ancient']['migration'] === 1)
                    {
                        $scores[$h11ihapi['id']]['score'] += 5;
                    }
                }
            }
        }
        // 去除未参与的行星
        foreach ($scores as $i => $s)
        {
            if ($s['num'] === 0)
            {
                unset($scores[$i]);
            }
        }
        $scores = resort($scores, 'score', 'DESC');
        //②取数值最高的前 4 个行星落座
        $newSigns = [];
        foreach ($scores as $ns)
        {
            $newSigns[] = [
                'id' => $planets[$ns['id']]['in_sign_id'],
                'power' => $ns['score'],
            ];
        }
        $newSigns = array_slice($newSigns, 0, 4);
        $useSigns = array_merge(array_unique(array_column($newSigns, 'id')));
        //④若最后少于 4 个行星落座，则增加
        if (count($useSigns) < 4)
        {
            // A、9 宫头落星座 B、11 宫头落星座、C、3 宫头落星座，D、命主星落星座。
            //取用原则：若已有取用星座，则取下一个。取用分值+5
            $house9InSign = $houses[9]['in_sign_id'];
            if (!in_array($house9InSign, $useSigns, false))
            {
                $useSigns[] = $house9InSign;
                $newSigns[] = [
                    'id' => $house9InSign,
                    'power' => 5
                ];
            }
            $house11InSign = $houses[11]['in_sign_id'];
            if (count($useSigns) < 4 && !in_array($house11InSign, $useSigns, false))
            {
                $useSigns[] = $house11InSign;
                $newSigns[] = [
                    'id' => $house11InSign,
                    'power' => 5
                ];
            }
            $house3InSign = $houses[3]['in_sign_id'];
            if (count($useSigns) < 4 && !in_array($house3InSign, $useSigns, false))
            {
                $useSigns[] = $house3InSign;
                $newSigns[] = [
                    'id' => $house3InSign,
                    'power' => 5
                ];
            }
            $house1InSign = $houses[1]['in_sign_id'];
            if (count($useSigns) < 4 && !in_array($house1InSign, $useSigns, false))
            {
                $useSigns[] = $house1InSign;
                $newSigns[] = [
                    'id' => $house1InSign,
                    'power' => 5
                ];
            }
        }

        //2、专业的取用
        //取用逻辑：总共取用 6 个专业
        /**
         * 0 => '哲学', 1 => '经济学', 2 => '法学', 3 => '教育学', 4 => '文学', 5 => '历史学',
         * 6 => '理学', 7 => '工学', 8 => '农学', 9 => '医学', 10 => '管理学', 11 => '艺术学'
         */
        $signMajors = [
            1 => [3, 9, 11],// 白羊座
            2 => [11, 5, 1],// 金牛座
            3 => [4, 11, 6, 3],// 双子座
            4 => [11, 5, 10, 8],// 巨蟹座
            5 => [11, 2, 10],// 狮子座
            6 => [1, 3, 6, 7, 9, 11],// 处女座
            7 => [11, 4, 2, 6],// 天秤座
            8 => [1, 9, 2, 6, 7],// 天蝎座
            9 => [0, 2, 4, 1, 10, 11, 3],// 射手座
            10 => [10, 7, 2, 8, 6, 9],// 摩羯座
            11 => [4, 7, 11, 6],// 水瓶座
            12 => [0, 11, 1],// 双鱼座
        ];

        // 第一星座
        if (isset($useSigns[0]))
        {
            //方式一、第一星座，可取 3 个专业，第二星座可取 2 个专业，第三星座可取 1 个专业
            // 第一星座所有专业
            $firstSignMajors = $signMajors[$useSigns[0]];
            $tags[] = 13030100 + $firstSignMajors[0];// + 最强专业
            $tags[] = 13030100 + $firstSignMajors[1];// + 第二专业
            $tags[] = 13030100 + $firstSignMajors[2];// + 第二专业
            // 将所有专业得分存储在「$levels[1]」中
            $levels['radar'][1][] = ['m' => $firstSignMajors[0], 's' => 0];
            $levels['radar'][1][] = ['m' => $firstSignMajors[1], 's' => 0];
            $levels['radar'][1][] = ['m' => $firstSignMajors[2], 's' => 0];
            $issetMajor = [$firstSignMajors[0], $firstSignMajors[1], $firstSignMajors[2]];
            if (isset($useSigns[1]))
            {
                // 第二星座所有专业
                $secondSignMajors = $signMajors[$useSigns[1]];
                foreach ($secondSignMajors as $ssm)
                {
                    if (count($issetMajor) < 5 && !in_array($ssm, $issetMajor, true))
                    {
                        $levels['radar'][1][] = ['m' => $ssm, 's' => 0];
                        $issetMajor[] = $ssm;
                    }
                }
                if (isset($useSigns[2]))
                {
                    // 第三星座所有专业
                    $thirdSignMajors = $signMajors[$useSigns[2]];
                    foreach ($thirdSignMajors as $tsm)
                    {
                        if (count($issetMajor) < 6 && !in_array($tsm, $issetMajor, true))
                        {
                            $levels['radar'][1][] = ['m' => $tsm, 's' => 0];
                            $issetMajor[] = $tsm;
                        }
                    }
                    if (isset($useSigns[3]))
                    {
                        // 第四星座所有专业
                        $fouthSignMajors = $signMajors[$useSigns[3]];
                        foreach ($fouthSignMajors as $fsm)
                        {
                            if (count($issetMajor) < 6 && !in_array($fsm, $issetMajor, true))
                            {
                                $levels['radar'][1][] = ['m' => $fsm, 's' => 0];
                                $issetMajor[] = $fsm;
                            }
                        }
                    }
                }
            }
        }
        // 影响星级 暂无算法
        $levels[1] = 1;

        //若有负分，则按第④原则取用计分
        $result = [
            'desc' => '主题4：适合你学习科目及专业',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 获取适合的科目
     * @param array $planets 行星数据
     * @param array $cond1 满足条件1的
     * @param int $allow 计算位置突出的行星的容许范围
     * @param array $res 返回的结果
     * @param int $need 需要计算出几条数据
     * @return array
     */
    private function getAdvantage($planets = [], $cond1 = [], &$allow = 10, &$res = [], $need = 2)
    {
        $cond2Planets = [1, 2, 3, 4, 6, 7, 8];
        // 位置突出的行星
        $cond2Meets = $this->getPostionPlanets($planets, $allow, $cond2Planets);
        $advantage = $this->getMajor($cond1, $cond2Meets);

        if ($advantage === -1)
        {
            if (in_array(4, $cond2Meets, true) && !in_array(8, $res, true))
            {
                $res[] = 8;
            }
        } else
        {
            if (!in_array($advantage, $res, true))
            {
                $res[] = $advantage;
            }
        }
        if (count($res) === $need)
        {
            return $res;
        }
        $allow += 10;
        return $this->getAdvantage($planets, $cond1, $allow, $res, $need);
    }

    /**
     * 【学业报告】获取位置突出的行星
     * 落在ASC或MC 10度之内合相
     * 或者落于角宫
     * @param array $planets 星体数据
     * @param int $allow 容许
     * @param array[number] $cond2Planets 要检测的星体
     * @return array
     */
    private function getPostionPlanets($planets, $allow, $cond2Planets): array
    {
        $result = [];
        $max = 360 - $allow;
        $min = $allow;

        foreach ($cond2Planets as $k => $p)
        {
            $diffASC = abs($planets[$p]['deg'] - $planets[17]['deg']);
            $diffMC = abs($planets[$p]['deg'] - $planets[20]['deg']);
            // 位置突出，记录
            if ($diffASC >= $max || $diffASC <= $min || $diffMC >= $max || $diffMC <= $min || in_array($planets[$p]['in_house_id'], [1, 4, 7, 10], true))
            {
                $result[] = [
                    'id' => $p,
                    'power' => $planets[$p]['ancient']['power']
                ];
            }
        }
        if (!empty($result))
        {
            $result = array_column(resort($result, 'power', 'DESC'), 'id');
        }
        return $result;
    }

    /**
     * 获取适合的专业
     * @param array[int] $cond 符合条件1的
     * @param array[int] $condMeets 位置突出的行星,按行星能量排序
     * @return int default -1 无结果
     */
    private function getMajor($cond, $condMeets): int
    {
        $advantage = -1;
        foreach ($cond as $c)
        {
            // 遍历突出的行星，已按照行星能量进行排序
            foreach ($condMeets as $cm)
            {
                // 文科
                if (in_array($c, [11, 21, 31], true))
                {
                    // 水星突出
                    if ($cm === 2)
                    {
                        $advantage = 0;
                        break;
                    }// 月亮突出
                    elseif ($cm === 1)
                    {
                        $advantage = 1;
                        break 2;
                    }// 金星突出
                    elseif ($cm === 3)
                    {
                        $advantage = 2;
                        break 2;
                    }
                }// 理科
                elseif (in_array($c, [12, 22, 32], true))
                {
                    // 水星突出
                    if ($cm === 2)
                    {
                        $advantage = 3;
                        break 2;
                    }// 土星突出
                    elseif ($cm === 6)
                    {
                        $advantage = 4;
                        break 2;
                    }// 天王突出
                    elseif ($cm === 7)
                    {
                        $advantage = 5;
                        break 2;
                    }
                }// 艺术
                elseif (in_array($c, [13, 23, 33], true))
                {
                    // 金星突出
                    if ($cm === 3)
                    {
                        $advantage = 6;
                        break 2;
                    }// 海王突出
                    elseif ($cm === 8)
                    {
                        $advantage = 7;
                        break 2;
                    }
                }// 文科 || 艺术
                else
                {
                    // 水星突出
                    if ($cm === 2)
                    {
                        $advantage = 0;
                        break 2;
                    }// 月亮突出
                    elseif ($cm === 1)
                    {
                        $advantage = 1;
                        break 2;
                    }// 金星突出
                    elseif ($cm === 3)
                    {
                        // 仅需判断 月亮、水星、金星、火星、土星、天王星、海王星
                        // $cond2Planets = [1, 2, 3, 4, 6, 7, 8];
                        // 如果只有金星、海王星突出，优先选择艺术
                        if (empty(array_intersect($condMeets, [1, 2, 4, 6, 7])))
                        {
                            $advantage = 6;
                            break 2;
                        } else
                        {
                            $advantage = 2;
                            break 2;
                        }
                    }// 海王突出
                    elseif ($cm === 8)
                    {
                        $advantage = 7;
                        break 2;
                    }
                }
            }
        }
        return $advantage;
    }

    /**
     * 学业报告 主题5：考证考试是否顺遂（300 字）
     */
    protected function getAcademicReportSection4()
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        // ①考试能力强弱+影响星级（200 字）
        // 会不会遇到困难、阻碍？还是一切顺利?
        // 三宫主先天得分
        // 3宫主
        $house3ProtectAncient = $houses[3]['protect_ancient_id'];
        // 3宫主先天得分
        $house3ProtectAncientPower = $planets[$house3ProtectAncient]['ancient']['power'];
        // 超过7分 得分5 顺利
        // 5分得分4 顺利
        // 3分得分3 一般
        // 0分得分2  困难
        // 低于0分 得分1 困难
        // 7*5*200=7000字
        if ($house3ProtectAncientPower > 7)
        {
            $state1 = 5;
        } elseif ($house3ProtectAncientPower > 5)
        {
            $state1 = 4;
        } elseif ($house3ProtectAncientPower > 3)
        {
            $state1 = 3;
        } elseif ($house3ProtectAncientPower >= 0)
        {
            $state1 = 2;
        } else
        {
            $state1 = 1;
        }
        $levels[] = $state1;
        // 宫主星 + 先天尊贵得分等级
        $tags[] = 130400000000 + $house3ProtectAncient * 100 + $state1 - 1;
        // 三宫宫内星暂时弃用
//        // 三宫落入行星
//        $house3PlanetsPower = [];
//        if (!empty($houses[3]['in_house_area_planet_info']))
//        {
//            foreach ($houses[3]['in_house_area_planet_info'] as $house3Planet)
//            {
//                $house3PlanetsPower[] = [
//                    'id' => $house3Planet['id'],
//                    'power' => $planets[$house3Planet['id']]['ancient']['power']
//                ];
//            }
//            $house3PlanetsPower = resort($house3PlanetsPower, 'power', 'DESC');
//        }
//        /**
//         * 行星按照先天尊贵正分负分确定强弱，>=0 为强    <0 为弱，
//         * 这个有就选最强的，标准和之前报告一致，没有就没有，这里主要做补充。增加变化
//         */
//        if (!empty($house3PlanetsPower))
//        {
//            $pid = $house3PlanetsPower[0];
//            if ($pid['power'] < 0)
//            {
//                $pid = end($house3PlanetsPower);
//            }
//            $tags[] = 130400010000 + $pid['id'] * 100 + ($pid['power'] >= 0 ? 0 : 1);// + 行星id*100 + 强0/弱1
//        }

        //②升学是否顺利+影响星级（200 字）
        //三宫主先天得分
        //超过7分 得分5 顺利
        //5分得分4 顺利
        //3分得分3 一般
        //0分得分2  困难
        //低于0分 得分1 困难
        $levels[] = $state1;
        //7个行星*5*200=7000字
        // 宫主星 + 先天尊贵得分等级
        $tags[] = 130401000000 + $house3ProtectAncient * 100 + $state1 - 1;
        // 以下暂时弃用
//        // 三宫主和其他行星的相位 7*2（坏和好）*50=700
//        /**
//         * 相位 60 120 是好的，90 180是不好的
//         * 0度看与之成相位的行星的尊贵，如果是正分是好，负分是不好
//         * 若为空相，则扩大到整个星座相位
//         * 以上相位只选择一个，得分最强的行星成的相位。
//         */
//        $house3ProtectAncientPhase = $planets[$house3ProtectAncient]['phase'];
//        if (empty($house3ProtectAncientPhase))
//        {
//            // 若为空相，则扩大到整个星座相位
//            $signPhaseConfig = [
//                'p1' => [$house3ProtectAncient],
//                'p2' => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
//                'asp' => [0 => 0, 30 => 1, 60 => 2, 90 => 3, 120 => 4, 150 => 5, 180 => 6],
//            ];
//            foreach ($signPhaseConfig['p1'] as $k1 => $p1)
//            {
//                foreach ($signPhaseConfig['p2'] as $p2)
//                {
//                    $p1Phasep2 = $p1 . '-' . $p2;// 过滤已有相位
//                    if ($p2 !== $p1 && !isset($house3ProtectAncientPhase[$p1Phasep2]))
//                    {
//                        $p1InSign = $planets[$p1]['in_sign_id'];
//                        $p2InSign = $planets[$p2]['in_sign_id'];
//                        foreach ($signPhaseConfig['asp'] as $ph => $asp)
//                        {
//                            $p1PhaseSign1 = $p1InSign + $asp;
//                            $p1PhaseSign2 = $p1InSign - $asp;
//                            $p1PhaseSign2 = $p1PhaseSign2 < 1 ? $p1PhaseSign2 + 12 : $p1PhaseSign2;
//                            if ($p2InSign === $p1PhaseSign1 || $p2InSign === $p1PhaseSign2)
//                            {
//                                // 行星一与行星2形成星座制相位
//                                $house3ProtectAncientPhase[] = [
//                                    'id' => $p2,
//                                    'phase' => $ph
//                                ];
//                            }
//                        }
//                    }
//
//                }
//            }
//        }
//
//        $house3PhasePlanetPower = $house3PhasePlanetId = $house3PhaseStatus = null;
//        foreach ($house3ProtectAncientPhase as $h3pap)
//        {
//            $ppp = $planets[$h3pap['id']]['ancient']['power'];
//            // 成相星体更强
//            if ($house3PhasePlanetPower === null || $ppp > $house3PhasePlanetPower)
//            {
//                $house3PhasePlanetId = $h3pap['id'];
//                if ($ppp > 0)
//                {
//                    $house3PhaseStatus = 0;
//                } else
//                {
//                    $house3PhaseStatus = 1;
//                }
//            }
//        }
//
//        $tags[] = 130401010000 + $house3PhasePlanetId * 100 + $house3PhaseStatus;// + 最强成相星体id*100 + 强0/弱1
//
//        // 三宫内行星
//        /**
//         * 这个有就选最强的，标准和之前报告一致，没有就没有，这里主要做补充。增加变化
//         */
//        if (!empty($house3PlanetsPower))
//        {
//            $pid = $house3PlanetsPower[0];
//            if ($pid['power'] < 0)
//            {
//                $pid = end($house3PlanetsPower);
//            }
//            $tags[] = 130401020000 + $pid['id'] * 100 + ($pid['power'] >= 0 ? 0 : 1);// + 行星id*100 + 强0/弱1
//        }

        $result = [
            'desc' => '主题5：考证考试是否顺遂',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 学业报告 主题6：最终学历高低
     */
    protected function getAcademicReportSection5()
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        $house3ProtectAncient = $houses[3]['protect_ancient_id'];// 3宫主
        $house6ProtectAncient = $houses[6]['protect_ancient_id'];// 6宫主
        $house9ProtectAncient = $houses[9]['protect_ancient_id'];// 9宫主
        // ①学历高低分析+影响星级（200 字）
        // 九宫主先天得分
        // 9宫主先天得分
        $house9ProtectAncientPower = $planets[$house9ProtectAncient]['ancient']['power'];
        // 超过7分 得分5 顺利
        // 5分得分4 顺利
        // 3分得分3 一般
        // 0分得分2  困难
        // 低于0分 得分1 困难
        // 7*5*200=7000字
        if ($house9ProtectAncientPower >= 7)
        {
            $state1 = 5;
        } elseif ($house9ProtectAncientPower >= 5)
        {
            $state1 = 4;
        } elseif ($house9ProtectAncientPower >= 3)
        {
            $state1 = 3;
        } elseif ($house9ProtectAncientPower >= 0)
        {
            $state1 = 2;
        } else
        {
            $state1 = 1;
        }
        $levels[] = $state1;
        // 7个行星*5*200=7000字
        // 需要区分宫主星 + 先天尊贵得分等级
        $tags[] = 130500000000 + $house9ProtectAncient * 100 + $state1 - 1;
        // 九宫主相位 7*2（坏和好）*50=700，3分以上只读好的，三分以下只读坏的
        /**
         * 相位 60 120 是好的，90 180是不好的
         * 0度看与之成相位的行星的尊贵，如果是正分是好，负分是不好
         * 若为空相，则扩大到整个星座相位
         * 以上相位只选择一个，得分最强的行星成的相位。
         */
        $house9ProtectAncientPhase = $planets[$house9ProtectAncient]['phase'];
        if (empty($house9ProtectAncientPhase))
        {
            // 若为空相，则扩大到整个星座相位
            $signPhaseConfig = [
                'p1' => [$house9ProtectAncient],
                'p2' => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
                'asp' => [0 => 0, 30 => 1, 60 => 2, 90 => 3, 120 => 4, 150 => 5, 180 => 6],
            ];
            foreach ($signPhaseConfig['p1'] as $k1 => $p1)
            {
                foreach ($signPhaseConfig['p2'] as $p2)
                {
                    $p1Phasep2 = $p1 . '-' . $p2;// 过滤已有相位
                    if ($p2 !== $p1 && $p2 < 7 && !isset($house9ProtectAncientPhase[$p1Phasep2]))
                    {
                        $p1InSign = $planets[$p1]['in_sign_id'];
                        $p2InSign = $planets[$p2]['in_sign_id'];
                        foreach ($signPhaseConfig['asp'] as $ph => $asp)
                        {
                            $p1PhaseSign1 = $p1InSign + $asp;
                            $p1PhaseSign2 = $p1InSign - $asp;
                            $p1PhaseSign2 = $p1PhaseSign2 < 1 ? $p1PhaseSign2 + 12 : $p1PhaseSign2;
                            if ($p2InSign === $p1PhaseSign1 || $p2InSign === $p1PhaseSign2)
                            {
                                // 行星一与行星2形成星座制相位
                                $house9ProtectAncientPhase[] = [
                                    'id' => $p2,
                                    'phase' => $ph
                                ];
                            }
                        }
                    }

                }
            }
        }

        $house9PhasePlanetPower = $house9PhasePlanetId = $house9PhaseStatus = null;
        foreach ($house9ProtectAncientPhase as $h9pap)
        {
            $ppp = $planets[$h9pap['id']]['ancient']['power'];
            // 成相星体更强
            if ($h9pap['id'] < 7 && ($house9PhasePlanetPower === null || $ppp > $house9PhasePlanetPower))
            {
                $house9PhasePlanetId = $h9pap['id'];
                if ($ppp > 0 && $house9PhasePlanetId < 7)
                {
                    $house9PhaseStatus = 0;
                } else
                {
                    $house9PhaseStatus = 1;
                }
            }
        }

        $tags[] = 130500010000 + $house9PhasePlanetId * 100 + $house9PhaseStatus;// + 成相星体id * 100 + 正面0/负面1

        // 九宫内行星 7*50=350
        $house9PlanetsPower = [];
        if (!empty($houses[9]['in_house_area_planet_info']))
        {
            foreach ($houses[9]['in_house_area_planet_info'] as $house9Planet)
            {
                if ($house9Planet['id'] < 7)
                {
                    $house9PlanetsPower[] = [
                        'id' => $house9Planet['id'],
                        'power' => $planets[$house9Planet['id']]['ancient']['power']
                    ];
                }
            }
            $house9PlanetsPower = resort($house9PlanetsPower, 'power', 'DESC');
        }
        /**
         * 这个有就选最强的，标准和之前报告一致，没有就没有，这里主要做补充。增加变化
         */
        if (!empty($house9PlanetsPower))
        {
            $tags[] = 1305000200 + $house9PlanetsPower[0]['id'];// + 行星id
        }


        // ②有无国外教育机会+影响星级（200 字）
        $condNum = $condScore = 0;
        $conds = [];
        // 1.上升射手   +1  100字 
        if ($planets[ASC]['in_sign_id'] === 9)
        {
            $condNum++;
            $condScore++;
            $conds[] = 0;
        }
        // 2.九宫宫主星落九宫 +1 100字 
        if ($planets[$house9ProtectAncient]['in_house_id'] === 9)
        {
            $condNum++;
            $condScore++;
            $conds[] = 1;

        }
        // 3.九宫宫主星落射手 +1 100字 
        if ($planets[$house9ProtectAncient]['in_sign_id'] === 9)
        {
            $condNum++;
            $condScore++;
            if ($condNum < 2)
            {
                $conds[] = 2;
            }
        }
        // 4.九宫有行星，有行星+1，日月+2 100字  700字 
        if (!empty($houses[9]['in_house_area_planet_info']))
        {
            $condNum++;
            if ($planets[0]['in_house_id'] === 9
                || $planets[1]['in_house_id'] === 9)
            {
                $condScore += 2;
            } else
            {
                $condScore++;
            }
            if ($condNum < 2)
            {
                $conds[] = 3;
            }
        }
        // 5.四宫有天王星或者木星   +1 200字
        if (!empty($houses[4]['in_house_area_planet_info'])
            && ($planets[7]['in_house_id'] === 4
                || $planets[5]['in_house_id'] === 4))
        {
            $condNum++;
            $condScore++;
            if ($condNum < 2)
            {
                $conds[] = 4;
            }
        }
        // 6.九宫宫头射手+1 100字 
        if ($houses[9]['in_sign_id'] === 9)
        {
            $condNum++;
            $condScore++;
            if ($condNum < 2)
            {
                $conds[] = 5;
            }
        }
        // 7.木星合上升+2或者一宫+1 200字 
        if (isset($planets[5]['phase']['5-17']) && $planets[5]['phase']['5-17']['phase_e'] === 0)
        {
            $condNum++;
            $condScore += 2;
            if ($condNum < 2)
            {
                $conds[] = 6;
            }
        } elseif ($planets[5]['in_house_id'] === 1)
        {
            $condNum++;
            $condScore++;
            if ($condNum < 2)
            {
                $conds[] = 6;
            }
        }
        // 8分及以上=5分， 6分=4分，4分=3分，2分=1分 其他0分
        if ($condScore >= 8)
        {
            $state2 = 5;
        } elseif ($condScore >= 6)
        {
            $state2 = 4;
        } elseif ($condScore >= 4)
        {
            $state2 = 3;
        } elseif ($condScore >= 2)
        {
            $state2 = 2;
        } else
        {
            $state2 = 1;
        }
        $levels[] = $state2;
        $tagList = [
            13050100,// 上升射手
            13050102,// 九宫主落九宫
            13050103,// 九宫主落射手
            1305010400,// 九宫宫内星 + 行星id
            13050106,// 四宫有天王星或者木星
            13050101,// 九宫头射手
            13050105,// 木星合上升或者一宫
        ];
        // 优选前两个条件显示 此处显示共200字
        if (!empty($conds))
        {
            $n = 0;
            // 条件ID为0-6，表示以上的1-7这七个条件
            foreach ($conds as $cd)
            {
                if ($n < 2)
                {
                    $tags[] = $tagList[$cd];
                    $n++;
                }
            }
        } else
        {
            $tags[] = 13050107;// 无国外教育机会
        }
        // ③有无社会教育（在职进修）机会+影响星级（200 字）
        /**
         * 日生盘 取水星-月亮
         * 夜生盘 取木星-火星-太阳
         */
        $mainFor20to40YearsOld = [];
        $mainPowerFor20to40YearsOld = 0;
        $yearsOld = 12;
        foreach ($this->firdariaData as $k => $firdaria)
        {
            // 主运行星
            $main = $firdaria['firdaria']['main_luck'];
            // 主运得分
            $power = $firdaria['planets'][$main]['ancient']['power'];
            if (!in_array($main, $mainFor20to40YearsOld) && $yearsOld >= 20 && $yearsOld <= 40)
            {
                $mainPowerFor20to40YearsOld += $power;
            }
            $yearsOld++;
        }
        $mainPowerFor20to40YearsOldCount = count($mainPowerFor20to40YearsOld);
        // 20岁-40岁，法达主运行星得分+第9宫宫主得分，取平均分，九宫主落入12宫位 12*200=2400字*2
        $score1 = ($mainPowerFor20to40YearsOld + $house9ProtectAncientPower) / ($mainPowerFor20to40YearsOldCount + 1);
        if ($score1 >= 8)
        {
            $state3_1 = 5;
        } elseif ($score1 >= 6)
        {
            $state3_1 = 4;
        } elseif ($score1 >= 4)
        {
            $state3_1 = 3;
        } elseif ($score1 >= 2)
        {
            $state3_1 = 2;
        } else
        {
            $state3_1 = 1;
        }
        $tags[] = 130502000000 + ($planets[$house9ProtectAncient]['in_house_id'] - 1) * 100 + $state3_1 - 1;// + (宫位 -1)  * 100) + 得分-1【1-5分】

        // 20岁-40岁，法达主运行星得分+第3宫宫主得分，取平均分，三宫主落入12宫位 12*200=2400字*2
        $score2 = ($mainPowerFor20to40YearsOld + $planets[$house3ProtectAncient]['ancient']['power']) / ($mainPowerFor20to40YearsOldCount + 1);
        if ($score2 >= 8)
        {
            $state3_2 = 5;
        } elseif ($score2 >= 6)
        {
            $state3_2 = 4;
        } elseif ($score2 >= 4)
        {
            $state3_2 = 3;
        } elseif ($score2 >= 2)
        {
            $state3_2 = 2;
        } else
        {
            $state3_2 = 1;
        }
        $tags[] = 130502010000 + ($planets[$house3ProtectAncient]['in_house_id'] - 1) * 100 + $state3_2 - 1;// + (宫位 -1 ) * 100) + 得分-1【1-5分】
        // 8分及以上=5分， 6分=4分，4分=3分，2分=1分 其他0分
        $score = ($score1 + $score2) / 2;
        if ($score >= 8)
        {
            $state3 = 5;
        } elseif ($score >= 6)
        {
            $state3 = 4;
        } elseif ($score >= 4)
        {
            $state3 = 3;
        } elseif ($score >= 2)
        {
            $state3 = 2;
        } else
        {
            $state3 = 1;
        }
        $levels[] = $state3;
//        if ($score1 >= $score2)
//        {
//            $tags[] = 130502000000 + ($planets[$house9ProtectAncient]['in_house_id'] - 1) * 100 + $state3_1 - 1;// + (宫位 -1)  * 100) + 得分-1【1-5分】
//        } else
//        {
//            $tags[] = 130502010000 + ($planets[$house3ProtectAncient]['in_house_id'] - 1) * 100 + $state3_2 - 1;// + (宫位 -1 ) * 100) + 得分-1【1-5分】
//        }

        // 新增词条调用逻辑：
        //①若 9 宫主落 12 宫、3 宫主落 12 宫，调用 3 分及以上词条，则仅调用 满足9/6宫主星太阳入 6/9宫的“好“的词条
        //②否则仅调用 满足9/6宫主星太阳入 6/9宫的“坏“的词条
        $powerTypeHouse3 = $planets[$house3ProtectAncient]['ancient']['power'] >= 0 ? 0 : 1;
        $powerTypeHouse6 = $planets[$house6ProtectAncient]['ancient']['power'] >= 0 ? 0 : 1;
        $powerTypeHouse9 = $planets[$house9ProtectAncient]['ancient']['power'] >= 0 ? 0 : 1;
        /**
         * 九宫主落入第六宫，或者第六宫主落入第九宫，2*7*100字。
         * 正负两个级别，如果两个都满足，选正分分高的那个，如果分数相同，选择六宫主落入第九宫这个
         */
        if ($planets[$house9ProtectAncient]['in_house_id'] === 6 && $planets[$house6ProtectAncient]['in_house_id'] !== 9)
        {

            if (($powerTypeHouse6 === 1 && $state3 <= 3) || ($powerTypeHouse6 === 0 && $state3 > 3))
            {
                $tags[] = 130502020000 + $house6ProtectAncient * 100 + $powerTypeHouse6;// + 宫主星*100 + 好0/坏1
            }
        } elseif ($planets[$house9ProtectAncient]['in_house_id'] !== 6 && $planets[$house6ProtectAncient]['in_house_id'] === 9)
        {
            if (($powerTypeHouse9 === 1 && $state3 <= 3) || ($powerTypeHouse9 === 0 && $state3 > 3))
            {
                $tags[] = 130502020000 + $house9ProtectAncient * 100 + $powerTypeHouse9;// + 宫主星*100 + 好0/坏1
            }
        } elseif ($planets[$house9ProtectAncient]['in_house_id'] === 6 && $planets[$house6ProtectAncient]['in_house_id'] === 9)
        {
            if ($planets[$house6ProtectAncient]['ancient']['power'] >= $planets[$house9ProtectAncient]['ancient']['power'])
            {
                if (($powerTypeHouse6 === 1 && $state3 <= 3) || ($powerTypeHouse6 === 0 && $state3 > 3))
                {
                    $tags[] = 130502020000 + $house6ProtectAncient * 100 + $powerTypeHouse6;
                }
            } else
            {
                if (($powerTypeHouse9 === 1 && $state3 <= 3) || ($powerTypeHouse9 === 0 && $state3 > 3))
                {
                    $tags[] = 130502020000 + $house9ProtectAncient * 100 + $powerTypeHouse9;
                }
            }
        }
        // 三宫主落入第六宫，第六宫主落入第三宫，2*7*100字。
        /**
         * 三宫主落入第六宫，第六宫主落入第三宫，2*7*100字。正负两个级别
         * 宫主得分，正分负分，如果两个都满足，选正分分高的那个，如果分数相同，选择三宫主落入第六宫这个
         */
        if ($planets[$house3ProtectAncient]['in_house_id'] === 6 && $planets[$house6ProtectAncient]['in_house_id'] !== 3)
        {
            if (($powerTypeHouse6 === 1 && $state3 <= 3) || ($powerTypeHouse6 === 0 && $state3 > 3))
            {

                $tags[] = 130502030000 + $house6ProtectAncient * 100 + ($powerTypeHouse6);// + 宫主星*100 + 好0/坏1
            }
        } elseif ($planets[$house3ProtectAncient]['in_house_id'] !== 6 && $planets[$house6ProtectAncient]['in_house_id'] === 3)
        {
            if (($powerTypeHouse3 === 1 && $state3 <= 3) || ($powerTypeHouse3 === 0 && $state3 > 3))
            {
                $tags[] = 130502030000 + $house3ProtectAncient * 100 + $powerTypeHouse3;// + 宫主星*100 + 好0/坏1
            }
        } elseif ($planets[$house3ProtectAncient]['in_house_id'] === 6 && $planets[$house6ProtectAncient]['in_house_id'] === 3)
        {
            if ($planets[$house6ProtectAncient]['ancient']['power'] >= $planets[$house3ProtectAncient]['ancient']['power'])
            {
                if (($powerTypeHouse6 === 1 && $state3 <= 3) || ($powerTypeHouse6 === 0 && $state3 > 3))
                {
                    $tags[] = 130502030000 + $house6ProtectAncient * 100 + $powerTypeHouse6;
                }
            } else
            {
                if (($powerTypeHouse3 === 1 && $state3 <= 3) || ($powerTypeHouse3 === 0 && $state3 > 3))
                {
                    $tags[] = 130502030000 + $house3ProtectAncient * 100 + $powerTypeHouse3;
                }
            }
        }

        $result = [
            'desc' => '主题6：最终学历高低',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 学业报告 主题7：学业对你人生的影响（600字）
     */
    protected function getAcademicReportSection6()
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        //①学业是否会成为你改变命运的机会+影响星级（200 字）
        $house3ProtectAncient = $houses[3]['protect_ancient_id'];
        $house6ProtectAncient = $houses[6]['protect_ancient_id'];
        $house9ProtectAncient = $houses[9]['protect_ancient_id'];
        $house10ProtectAncient = $houses[10]['protect_ancient_id'];

        $hp3PhHp10 = $house3ProtectAncient . '-' . $house10ProtectAncient;
        $hp9PhHp10 = $house9ProtectAncient . '-' . $house10ProtectAncient;
        $hp3PhPmc = $house3ProtectAncient . '-20';
        $hp9PhPmc = $house9ProtectAncient . '-20';
        $hp3PhHp6 = $house3ProtectAncient . '-' . $house6ProtectAncient;
        $hp9PhHp6 = $house9ProtectAncient . '-' . $house6ProtectAncient;

        // 以下不扩大整宫，容许度为本命星盘容许度
        // 1、 评级 影响得分$is、相位因素$ps
        /**
         * $score1 3宫影响
         * $score2 9宫影响
         */
        $score1 = $score2 = 0;
        // 3宫主与10宫主有相位
        if (isset($planets[$house3ProtectAncient]['phase'][$hp3PhHp10]))
        {
            switch ($planets[$house3ProtectAncient]['phase'][$hp3PhHp10]['phase_e'])
            {
                case 60:
                case 120:
                    $score1 += 2 * 1;
                    break;
                case 90:
                case 180:
                    $score1 += 2 * -1;
                    break;
                case 0:
                    if ($planets[$house3ProtectAncient]['ancient']['power'] >= 0)
                    {
                        $score1 += 2 * 1;
                    } else
                    {
                        $score1 += 2 * -1;
                    }
                    break;
            }
        }
        // 9宫主与10宫主有相位
        if (isset($planets[$house9ProtectAncient]['phase'][$hp9PhHp10]))
        {
            switch ($planets[$house9ProtectAncient]['phase'][$hp9PhHp10]['phase_e'])
            {
                case 60:
                case 120:
                    $score2 += 2 * 1;
                    break;
                case 90:
                case 180:
                    $score2 += 2 * -1;
                    break;
                case 0:
                    if ($planets[$house9ProtectAncient]['ancient']['power'] >= 0)
                    {
                        $score2 += 2 * 1;
                    } else
                    {
                        $score2 += 2 * -1;
                    }
                    break;
            }
        }
        // 3宫主与MC有相位
        if (isset($planets[$house3ProtectAncient]['phase'][$hp3PhPmc]))
        {
            switch ($planets[$house3ProtectAncient]['phase'][$hp3PhPmc]['phase_e'])
            {
                case 60:
                case 120:
                    $score1 += 2 * 1;
                    break;
                case 90:
                case 180:
                    $score1 += 2 * -1;
                    break;
                case 0:
                    if ($planets[$house3ProtectAncient]['ancient']['power'] >= 0)
                    {
                        $score1 += 2 * 1;
                    } else
                    {
                        $score1 += 2 * -1;
                    }
                    break;
            }
        }
        // 9宫主与MC有相位
        if (isset($planets[$house9ProtectAncient]['phase'][$hp9PhPmc]))
        {
            switch ($planets[$house9ProtectAncient]['phase'][$hp9PhPmc]['phase_e'])
            {
                case 60:
                case 120:
                    $score2 += 2 * 1;
                    break;
                case 90:
                case 180:
                    $score2 += 2 * -1;
                    break;
                case 0:
                    if ($planets[$house9ProtectAncient]['ancient']['power'] >= 0)
                    {
                        $score2 += 2 * 1;
                    } else
                    {
                        $score2 += 2 * -1;
                    }
                    break;
            }
        }
        // 3宫主与6宫主有相位
        if (isset($planets[$house3ProtectAncient]['phase'][$hp3PhHp6]))
        {
            switch ($planets[$house3ProtectAncient]['phase'][$hp3PhHp6]['phase_e'])
            {
                case 60:
                case 120:
                    $score1 += 2 * 1;
                    break;
                case 90:
                case 180:
                    $score1 += 2 * -1;
                    break;
                case 0:
                    if ($planets[$house3ProtectAncient]['ancient']['power'] >= 0)
                    {
                        $score1 += 2 * 1;
                    } else
                    {
                        $score1 += 2 * -1;
                    }
                    break;
            }
        }
        // 9宫主与6宫主有相位
        if (isset($planets[$house9ProtectAncient]['phase'][$hp9PhHp6]))
        {
            switch ($planets[$house9ProtectAncient]['phase'][$hp9PhHp6]['phase_e'])
            {
                case 60:
                case 120:
                    $score2 += 2 * 1;
                    break;
                case 90:
                case 180:
                    $score2 += 2 * -1;
                    break;
                case 0:
                    if ($planets[$house9ProtectAncient]['ancient']['power'] >= 0)
                    {
                        $score2 += 2 * 1;
                    } else
                    {
                        $score2 += 2 * -1;
                    }
                    break;
            }
        }
        // 6宫头度数
        $house6Deg = $houses[6]['deg'];
        // 3宫主容许度
        $house3ProtectAncientAllow = $this->setting3['natal']['planet'][$house3ProtectAncient][1];
        // 9宫主容许度
        $house9ProtectAncientAllow = $this->setting3['natal']['planet'][$house9ProtectAncient][1];
        $ishouse3PkHouse6 = $ishouse9PkHouse6 = false;
        foreach ($this->setting3['natal']['phase'] as $asp_deg => $asp)
        {
            if ($asp[0] === 1)
            {
                $asp_deg_orb = $asp[1];
                // 3宫主与6宫头有相位
                if ($ishouse3PkHouse6 === false)
                {
                    // 3宫主与6宫头相差的度数
                    $degDiff1 = abs($planets[$house3ProtectAncient]['deg'] - $house6Deg);
                    $degDiff1 = $degDiff1 > 180 ? 360 - $degDiff1 : $degDiff1;
                    if ($degDiff1 <= ($asp_deg + $asp_deg_orb + $house3ProtectAncientAllow) && $degDiff1 >= ($asp_deg - $asp_deg_orb - $house3ProtectAncientAllow))
                    {
                        $ishouse3PkHouse6 = true;
                        switch ($asp_deg)
                        {
                            case 60:
                            case 120:
                                $score1 += 2 * 1;
                                break;
                            case 90:
                            case 180:
                                $score1 += 2 * -1;
                                break;
                            case 0:
                                if ($planets[$house3ProtectAncient]['ancient']['power'] >= 0)
                                {
                                    $score1 += 2 * 1;
                                } else
                                {
                                    $score1 += 2 * -1;
                                }
                                break;
                        }
                    }
                }
                // 9宫主与6宫头有相位
                if ($ishouse9PkHouse6 === false)
                {
                    // 3宫主与6宫头相差的度数
                    $degDiff2 = abs($planets[$house9ProtectAncient]['deg'] - $house6Deg);
                    $degDiff2 = $degDiff2 > 180 ? 360 - $degDiff2 : $degDiff2;
                    if ($degDiff2 <= ($asp_deg + $asp_deg_orb + $house9ProtectAncientAllow) && $degDiff2 >= ($asp_deg - $asp_deg_orb - $house9ProtectAncientAllow))
                    {
                        $ishouse9PkHouse6 = true;
                        switch ($asp_deg)
                        {
                            case 60:
                            case 120:
                                $score2 += 2 * 1;
                                break;
                            case 90:
                            case 180:
                                $score2 += 2 * -1;
                                break;
                            case 0:
                                if ($planets[$house9ProtectAncient]['ancient']['power'] >= 0)
                                {
                                    $score2 += 2 * 1;
                                } else
                                {
                                    $score2 += 2 * -1;
                                }
                                break;
                        }
                    }
                }
            }
        }
        // 6宫内有行星
        if (!empty($houses[6]['in_house_area_planet_info']))
        {
            $h6pPhH3s = $h6pPhH9s = [];
            // 查找成相星体
            foreach ($houses[6]['in_house_area_planet_info'] as $h6p)
            {
                $h6pPhH3 = $h6p['id'] . '-' . $house3ProtectAncient;
                $h6pPhH9 = $h6p['id'] . '-' . $house9ProtectAncient;

                // 与3宫主成相
                if (isset($planets[$h6p['id']]['phase'][$h6pPhH3]))
                {
                    $h6pPhH3s[] = [
                        'id' => $h6p['id'],
                        'phase_e' => $planets[$h6p['id']]['phase'][$h6pPhH3]['phase_e'],
                        'power' => $planets[$h6p['id']]['ancient']['power']
                    ];
                }
                // 与9宫主成相
                if (isset($planets[$h6p['id']]['phase'][$h6pPhH9]))
                {
                    $h6pPhH9s[] = [
                        'id' => $h6p['id'],
                        'phase_e' => $planets[$h6p['id']]['phase'][$h6pPhH9]['phase_e'],
                        'power' => $planets[$h6p['id']]['ancient']['power']
                    ];
                }
            }
            // 3宫主与6宫内行星有相位 （宫内多个行星计算尊贵最强的一个）
            if (!empty($h6pPhH3s))
            {
                $h6pPhH3s = resort($h6pPhH3s, 'power', 'DESC');
                switch ($h6pPhH3s[0]['phase_e'])
                {
                    case 60:
                    case 120:
                        $score1 += 1 * 1;
                        break;
                    case 90:
                    case 180:
                        $score1 += 1 * -1;
                        break;
                    case 0:
                        if ($h6pPhH3s[0]['power'] >= 0)
                        {
                            $score1 += 1 * 1;
                        } else
                        {
                            $score1 += 1 * -1;
                        }
                        break;
                }
            }
            // 9宫主与6宫内行星有相位 （宫内多个行星计算尊贵最强的一个）
            if (!empty($h6pPhH9s))
            {
                $h6pPhH9s = resort($h6pPhH9s, 'power', 'DESC');
                switch ($h6pPhH9s[0]['phase_e'])
                {
                    case 60:
                    case 120:
                        $score2 += 1 * 1;
                        break;
                    case 90:
                    case 180:
                        $score2 += 1 * -1;
                        break;
                    case 0:
                        if ($h6pPhH9s[0]['power'] >= 0)
                        {
                            $score2 += 1 * 1;
                        } else
                        {
                            $score2 += 1 * -1;
                        }
                        break;
                }
            }
        }
        // 10宫内有行星
        if (!empty($houses[10]['in_house_area_planet_info']))
        {
            $h10pPhH3s = $h10pPhH9s = [];
            // 查找成相星体
            foreach ($houses[6]['in_house_area_planet_info'] as $h10p)
            {
                $h10pPhH3 = $h10p['id'] . '-' . $house3ProtectAncient;
                $h10pPhH9 = $h10p['id'] . '-' . $house9ProtectAncient;

                // 与3宫主成相
                if (isset($planets[$h10p['id']]['phase'][$h10pPhH3]))
                {
                    $h10pPhH3s[] = [
                        'id' => $h10p['id'],
                        'phase_e' => $planets[$h10p['id']]['phase'][$h10pPhH3]['phase_e'],
                        'power' => $planets[$h10p['id']]['ancient']['power']
                    ];
                }
                // 与9宫主成相
                if (isset($planets[$h10p['id']]['phase'][$h10pPhH9]))
                {
                    $h10pPhH9s[] = [
                        'id' => $h10p['id'],
                        'phase_e' => $planets[$h10p['id']]['phase'][$h10pPhH9]['phase_e'],
                        'power' => $planets[$h10p['id']]['ancient']['power']
                    ];
                }
            }
            // 3宫主与10宫内行星有相位 （宫内多个行星计算尊贵最强的一个）
            if (!empty($h10pPhH3s))
            {
                $h10pPhH3s = resort($h10pPhH3s, 'power', 'DESC');
                switch ($h10pPhH3s[0]['phase_e'])
                {
                    case 60:
                    case 120:
                        $score1 += 1 * 1;
                        break;
                    case 90:
                    case 180:
                        $score1 += 1 * -1;
                        break;
                    case 0:
                        if ($h10pPhH3s[0]['power'] >= 0)
                        {
                            $score1 += 1 * 1;
                        } else
                        {
                            $score1 += 1 * -1;
                        }
                        break;
                }
            }
            // 9宫主与10宫内行星有相位 （宫内多个行星计算尊贵最强的一个）
            if (!empty($h10pPhH9s))
            {
                $h10pPhH9s = resort($h10pPhH9s, 'power', 'DESC');
                switch ($h10pPhH9s[0]['phase_e'])
                {
                    case 60:
                    case 120:
                        $score2 += 1 * 1;
                        break;
                    case 90:
                    case 180:
                        $score2 += 1 * -1;
                        break;
                    case 0:
                        if ($h10pPhH9s[0]['power'] >= 0)
                        {
                            $score2 += 1 * 1;
                        } else
                        {
                            $score2 += 1 * -1;
                        }
                        break;
                }
            }
        }
        // 3宫主落10宫（落入算合相，看宫主星最贵）
        if ($planets[$house3ProtectAncient]['in_house_id'] === 10)
        {
            if ($planets[$house3ProtectAncient]['ancient']['power'] >= 0)
            {
                $score1 += 1 * 1;
            } else
            {
                $score1 += 1 * -1;
            }
        }
        // 9宫主落10宫（落入算合相，看宫主星最贵）
        if ($planets[$house9ProtectAncient]['in_house_id'] === 10)
        {
            if ($planets[$house9ProtectAncient]['ancient']['power'] >= 0)
            {
                $score2 += 1 * 1;
            } else
            {
                $score2 += 1 * -1;
            }
        }
        // 10宫主落入3宫
        if ($planets[$house10ProtectAncient]['in_house_id'] === 3)
        {
            if ($planets[$house10ProtectAncient]['ancient']['power'] >= 0)
            {
                $score1 += 1 * 1;
            } else
            {
                $score1 += 1 * -1;
            }
        }// 10宫主落入9宫
        elseif ($planets[$house10ProtectAncient]['in_house_id'] === 9)
        {
            if ($planets[$house10ProtectAncient]['ancient']['power'] >= 0)
            {
                $score2 += 1 * 1;
            } else
            {
                $score2 += 1 * -1;
            }
        }
        /**
         * 三宫主影响比例：，尊贵超过5分为100%，高于等于0分为50%分，低于零分0%
         * 三宫最后影响：（影响得分*相位因素）求和*三宫主影响比例
         */
        if ($planets[$house3ProtectAncient]['ancient']['power'] < 0)
        {
            $score1 = 0;
        } elseif ($planets[$house3ProtectAncient]['ancient']['power'] < 5)
        {
            $score1 *= 0.5;
        }
        /**
         * 九宫主影响比例：，尊贵超过5分为100%，高于等于0分为50%分，低于零分0%
         * 九宫最后影响：（影响得分*相位因素）求和*九宫主影响比例
         */
        if ($planets[$house9ProtectAncient]['ancient']['power'] < 0)
        {
            $score2 = 0;
        } elseif ($planets[$house9ProtectAncient]['ancient']['power'] < 5)
        {
            $score2 *= 0.5;
        }
        if ($score1 > $score2)
        {
            $max = $score1;
        } else
        {
            $max = $score2;
        }
        /**
         * e.选择影响分最高的，如果相同，就选按这个分做评级
         * 超过8分  星级5
         * 超过5分  星级4
         * 超过3分 星级3
         * 超过2分 星级4
         * 低于0分 星级1
         */
        if ($max >= 8)
        {
            $state1 = 5;
        } else if ($max >= 5)
        {
            $state1 = 4;
        } else if ($max >= 3)
        {
            $state1 = 3;
        } else if ($max >= 2)
        {
            $state1 = 2;
        } else
        {
            $state1 = 1;
        }
        $levels[] = $state1;

        /**
         * 调取解释，
         * （1）选择三和九宫主，得分高的一个。如果得分相同，
         *      1、就按照三宫主九宫主自身的尊贵得分，
         *      2、还相同加上三宫主尊贵的分+三宫主所在位置term得分，和九宫主比，取高分。
         *      3、如果得分仍然相同，按照行星天然顺序，太阳到土星选择。
         * （2）选取三宫主和九宫主得分高的宫主星。显示三宫主，九宫主和十宫主有相位解释。
         */
        if ($score1 > $score2)
        {
            // 3宫主
            $tags[] = 130600000000 + $house3ProtectAncient * 100 + $state1 - 1;// 3宫主id * 100 + 星级
        } else
        {
            // 9宫主
            $tags[] = 130600010000 + $house9ProtectAncient * 100 + $state1 - 1;// 9宫主id * 100 + 星级
        }

        //②学业阶段性发展趋势+影响星级（400 字）
        //给出阶段性的评价，比如早期可能学业不够顺利，后期会比较顺利
        $yearsOld = 12;
        /**
         * 早年 $stage1
         * 18岁前：3宫主得分+18岁之前两个法达（主运）得分，三个星取平均分
         * 中期 $stage2
         * 18岁-30岁：9宫主得分+18岁-40岁两个法达（主运）得分，三个星取平均分
         * 后期 $stage3
         * 30岁之后：（9宫主+三宫主平均得分）+30-40岁法达（主运）得分，4个星取平均分
         */
        $stage1 = $stage2 = $stage3 = [];
        $s1 = $s2 = $s3 = 0;
        $n1 = $n2 = $n3 = 0;
        foreach ($this->firdariaData as $k => $firdaria)
        {
            // 主运行星
            $main = $firdaria['firdaria']['main_luck'];
            // 主运得分
            $power = $firdaria['planets'][$main]['ancient']['power'];
            if ($yearsOld < 18)
            {
                if (!in_array($main, $stage1))
                {
                    $stage1[] = $main;
                    $s1 += $power;
                    $n1++;
                }
            } elseif ($yearsOld <= 30)
            {
                if (!in_array($main, $stage2))
                {
                    $stage2[] = $main;
                    $s2 += $power;
                    $n2++;
                }
            } elseif ($yearsOld <= 40)
            {
                if (!in_array($main, $stage3))
                {
                    $stage3[] = $main;
                    $s3 += $power;
                    $n3++;
                }
            }
            $yearsOld++;
        }
        $s3 += ($planets[$house3ProtectAncient]['ancient']['power'] + $planets[$house9ProtectAncient]['ancient']['power']) / 2;
        $n3++;
        $a1 = $n1 ? $s1 / $n1 : 0;
        // 大于5分很顺利，大于3分顺利，大于0分一般，低于0分不顺利，-3分非常不顺利
        if ($a1 >= 5)
        {
            $st1 = 5;
        } elseif ($a1 >= 3)
        {
            $st1 = 4;
        } elseif ($a1 >= 3)
        {
            $st1 = 3;
        } elseif ($a1 >= 3)
        {
            $st1 = 2;
        } else
        {
            $st1 = 1;
        }
        $a2 = $n2 ? $s2 / $n2 : 0;
        // 大于5分很顺利，大于3分顺利，大于0分一般，低于0分不顺利，-3分非常不顺利
        if ($a2 >= 5)
        {
            $st2 = 5;
        } elseif ($a2 >= 3)
        {
            $st2 = 4;
        } elseif ($a2 >= 3)
        {
            $st2 = 3;
        } elseif ($a2 >= 3)
        {
            $st2 = 2;
        } else
        {
            $st2 = 1;
        }
        $a3 = $n3 ? $s3 / $n3 : 0;
        // 大于5分很顺利，大于3分顺利，大于0分一般，低于0分不顺利，-3分非常不顺利
        if ($a3 >= 5)
        {
            $st3 = 5;
        } elseif ($a3 >= 3)
        {
            $st3 = 4;
        } elseif ($a3 >= 3)
        {
            $st3 = 3;
        } elseif ($a3 >= 3)
        {
            $st3 = 2;
        } else
        {
            $st3 = 1;
        }

        //这里会有三段描述，
        // 早期：按照平均分，读取第三宫宫主星 解释，
        $tags[] = 130601000000 + $house3ProtectAncient * 100 + $st1 - 1;// + 3宫主行星ID*100 + 星级
        // 中期：读取第九宫宫主星
        $tags[] = 130601010000 + $house9ProtectAncient * 100 + $st2 - 1;// + 9宫主行星ID*100 + 星级
        // 后期：读取第九宫宫主星+第三宫宫主星的解释，取第三宫或者第九宫分高的这个。
        $tagForHouse3 = 130601020000 + $house3ProtectAncient * 100 + $st3 - 1;// + 3宫主行星ID*100 + 星级
        $tagForHouse9 = 130601020000 + $house9ProtectAncient * 100 + $st3 - 1;// + 3宫主行星ID*100 + 星级
        /**
         * 1、 得分相同的请情况下，如果此时法达主运运势30-40岁阶段走其中一个，选择这个行星。
         * 2、 如果法达都没有，法达主运星是否落入三宫和九宫，如果落入，那么选择这个宫主星。
         * 3、 如果都没有选择三宫主+三宫主定位星 的得分比九宫主+九宫主定位星的得分，选强的。
         * 4、 再没有按照行星顺序。
         */
        if ($planets[$house3ProtectAncient]['ancient']['power'] > $planets[$house9ProtectAncient]['ancient']['power'])
        {
            $tags[] = $tagForHouse3;// + 3宫主行星ID*100 + 星级
        } else if ($planets[$house3ProtectAncient]['ancient']['power'] === $planets[$house9ProtectAncient]['ancient']['power'])
        {
            $house3ProtectAncientIsMain = $house9ProtectAncientIsMain = false;
            // 法达主运星为3宫主
            if (in_array($house3ProtectAncient, $stage3))
            {
                $house3ProtectAncientIsMain = true;
            }
            // 法达主运星为9宫主
            if (in_array($house9ProtectAncient, $stage3))
            {
                $house9ProtectAncientIsMain = true;
            }
            // 法达主运星为3宫主且不为9宫主
            if ($house3ProtectAncientIsMain && !$house9ProtectAncientIsMain)
            {
                $tags[] = $tagForHouse3;// + 3宫主行星ID*100 + 星级
            }// 法达主运星为9宫主且不为3宫主
            elseif (!$house3ProtectAncientIsMain && $house9ProtectAncientIsMain)
            {
                $tags[] = $tagForHouse9;// + 9宫主行星ID*100 + 星级
            }// 法达主运星为3宫主且是9宫主，或既不为3宫主也不为9宫主
            else
            {
                $isMainInHouse3 = $isMainInHouse9 = false;

                foreach ($stage3 as $sta3)
                {
                    // 法达主运星落入3宫
                    if ($isMainInHouse3 === false && $planets[$sta3]['in_house_id'] === 3)
                    {
                        $isMainInHouse3 = true;
                    }
                    // 法达主运星落入9宫
                    if ($isMainInHouse9 === false && $planets[$sta3]['in_house_id'] === 9)
                    {
                        $isMainInHouse9 = true;
                    }
                }
                if ($isMainInHouse3 && !$isMainInHouse9)
                {
                    $tags[] = $tagForHouse3;
                } elseif (!$isMainInHouse3 && $isMainInHouse9)
                {
                    $tags[] = $tagForHouse9;
                } else
                {
                    $signProtectAncients = config('astrolog.protect_ancient_id');
                    // 3宫主定位星
                    $house3ProtectPlanetId = $signProtectAncients[$planets[$house3ProtectAncient]['in_sign_id'] - 1];
                    $power3 = $planets[$house3ProtectAncient]['ancient']['power'] + $planets[$house3ProtectPlanetId]['ancient']['power'];
                    // 9宫主定位星
                    $house9ProtectPlanetId = $signProtectAncients[$planets[$house9ProtectAncient]['in_sign_id'] - 1];
                    $power9 = $planets[$house9ProtectAncient]['ancient']['power'] + $planets[$house9ProtectPlanetId]['ancient']['power'];

                    if ($power3 > $power9)
                    {
                        $tags[] = $tagForHouse3;
                    } elseif ($power3 < $power9)
                    {
                        $tags[] = $tagForHouse9;
                    } else
                    {
                        if ($house3ProtectAncient < $house9ProtectAncient)
                        {
                            $tags[] = $tagForHouse3;// + 3宫主行星ID*100 + 星级
                        } else
                        {
                            $tags[] = $tagForHouse9;// + 9宫主行星ID*100 + 星级
                        }
                    }
                }
            }
        } else
        {
            $tags[] = $tagForHouse9;// + 9宫主行星ID*100 + 星级
        }
        $result = [
            'desc' => '主题7：学业对你人生的影响',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 婚姻报告 主题1（曲线图）婚姻机缘高低的年份（20-80）
     * @return array
     */
    protected function getDatingCurveData(): array
    {
        $levels = [];
        $startYearsOld = 20;
        // 18-80岁之间的法达盘
        foreach ($this->firdariaData as $k => $firdaria)
        {
            $main = $firdaria['firdaria']['main_luck'];
            $sub = $firdaria['firdaria']['sub_luck'];
            // 默认5分，加减分后，按照此画图
            $p = 5;

            //1、18-60岁之间，次限月亮正好进入本命第七宫的时间段。每28年，1种可能（必然有）+5
            if ($startYearsOld >= 18 && $startYearsOld <= 60 && $this->progressionsvsnatalData[$k]['planets'][1]['in_house_id'] === 7)
            {
                $p += 3;
            }
            //2、本命第7宫宫主星，是法达副运主星值限。每70年7种可能（必然有）+3
            if ($firdaria['houses'][7]['protect_ancient_id'] === $sub)
            {
                $p += 3;
            }
            //3、本命第七宫内行星副运+1
            if ($firdaria['planets'][$sub]['in_house_id'] === 7)
            {
                $p++;
            }
            //4、法达主运是第七宫宫主星的时候+1
            if ($firdaria['houses'][7]['protect_ancient_id'] === $main)
            {
                $p++;
            }
            //5、土星火星主宰年份-1分（不管是不是主星）
            if (in_array($sub, [4, 6], true))
            {
                $p--;
            }
            //6、20-30岁+1
            if ($startYearsOld >= 20 && $startYearsOld <= 30)
            {
                $p++;
            } //40岁-50+1
            elseif ($startYearsOld >= 40 && $startYearsOld <= 50)
            {
                $p++;
            } //50岁以后-1
            elseif ($startYearsOld > 50)
            {
                $p--;
            }

            $startYearsOld++;

            $levels[] = $p;
        }

        $result = [
            'desc' => '主题 1：（曲线图）婚姻机缘高低的年份（20-80）',
            'content_list' => [],
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 婚姻报告 主题 2：婚姻特质
     * @return array
     */
    protected function getDatingReportSection1(): array
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        //①婚姻特质+影响星级 100*12=1200字
        //一句话呈现，一生婚姻关键词，婚神星落入十二个星座
        $tags[] = 14010000 + $planets[13]['in_sign_id'] - 1;

        //②结婚是否顺遂+影响星级 7*5*100=3500
        //第五宫宫主得分
        $house5ProtectAncient = $houses[5]['protect_ancient_id'];
        $house5ProtectAncientPower = $planets[$houses[5]['protect_ancient_id']]['ancient']['power'];
        //5分=得分高于5分
        //4分=得分3-5
        //3分=得分大于0
        //2分=得分大于-3
        //1分=低于-3
        if ($house5ProtectAncientPower >= 5)
        {
            $state2 = 5;
        } elseif ($house5ProtectAncientPower >= 3)
        {
            $state2 = 4;
        } elseif ($house5ProtectAncientPower >= 0)
        {
            $state2 = 3;
        } elseif ($house5ProtectAncientPower >= -3)
        {
            $state2 = 2;
        } else
        {
            $state2 = 1;
        }
        $tags[] = 1401010000 + $house5ProtectAncient * 100 + $state2 - 1;

        //③早婚还是晚婚+影响星级
        //（1）先判断早婚晚婚，计算早晚婚结婚率
        //注：晚婚28岁以后，早婚28岁以前
        //早婚的征象（1500字）
        // 符合条件的数组 array(number)，里面存放 符合的条件ID，如：满足条件1 和3  则[1,3]
        $earlyConds = [];// 早婚条件
        $laterConds = [];// 晚婚条件

        // 用户出生时间转换成0时区时间字符串
        $date = date('Y-m-d H:i', Astrolog::getInstance()->dealTime($this->recode));
        // 月盈 ( 从新月到满月 ) 的时段内出生 or 月亏 ( 从满月到新月 ) 的时段内出生
        $isWangxingMoon = (new SyzygyTIme())->isWaxingMoon($date);

        // 日月金火具有的吉相数量
        $planetsGoodPhaseNum = [0 => 0, 1 => 0, 3 => 0, 4 => 0];
        // 日月金火木是否具有两个及以上的吉相
        $isPlanetsGoodPhaseNumMoreTwo = [0 => false, 1 => false, 3 => false, 4 => false, 5 => false];
        // 判断行星是否具有两个及以上的吉相
        foreach ($planetsGoodPhaseNum as $p1 => $num)
        {
            if (!empty($planets[$p1]['phase']))
            {
                foreach ($planets[$p1]['phase'] as $phase)
                {
                    if ($phase['id'] < 10 && in_array($phase['phase_e'], [60, 120], true))
                    {
                        $planetsGoodPhaseNum[$p1]++;
                    }
                }
                if ($planetsGoodPhaseNum[$p1] >= 2)
                {
                    $isPlanetsGoodPhaseNumMoreTwo[$p1] = true;
                }
            }
        }

        $accordingJust = $this->astroData['according']['just'];// 赤纬平行数据，此处不需要反纬照
        $ajs = [];
        foreach ($accordingJust as $aj)
        {
            $ajs[] = implode('-', $aj);
        }
        /**
         * 0 => 早婚
         * 1 => 晚婚
         */
        $text = [0 => [], 1 => []];
        $signToTextIndex1 = [2 => 0, 4 => 1, 8 => 2, 12 => 3];
        $signToTextIndex2 = [1 => 0, 3 => 1, 5 => 2, 6 => 3, 10 => 4];
        $signToTextIndex3 = [1 => 0, 5 => 1, 6 => 2, 10 => 3];
        $planetToTextIndex1 = [4 => 0, 6 => 1, 7 => 2, 8 => 3, 9 => 4];
        $recodeSex = $this->recode['type'] * 1 === 1 ? 1 : 2;// 性别
        $house5ProtectAncient = $houses[5]['protect_ancient_id'];
        $house7ProtectAncient = $houses[7]['protect_ancient_id'];
        // 男
        if ($recodeSex === 1)
        {
            $earlyCondsMax = 7;
            $laterCondsMax = 11;
            // 第一，如果他是在月盈 ( 从新月到满月 ) 的时段内出生，而且月亮又正好是落在第四宫、第五宫、第六宫、第十宫、第十一宫或第十二宫内。
            if (in_array($planets[1]['in_house_id'], [4, 5, 6, 10, 11, 12], true))
            {
                // 月盈
                if ($isWangxingMoon)
                {
                    $earlyConds[] = 1;
                    $text[0][1] = 1401020000;
                }
            }// 第一，如果他是在月亏 ( 从满月到新月 ) 的时段内出生，而且月亮又正好是落在第一宫、第二宫、第三宫、第七宫、第八宫或第九宫内。
            else
            {
                // 月亏
                if (!$isWangxingMoon)
                {
                    $laterConds[] = 1;
                    $text[1][1] = 1401020200;
                }
            }

            // 第三，如果月亮或金星是落在金牛座、巨蟹座、天蝎座或双鱼座内，并且与其他的行星形成两个以上的主吉相，而且又正好是落在始宫内。
            if ($isPlanetsGoodPhaseNumMoreTwo[1] && in_array($planets[1]['in_house_id'], [1, 4, 7, 10], true)
                && in_array($planets[1]['in_sign_id'], [2, 4, 8, 12], true))
            {
                $earlyConds[] = 3;
                $text[0][3] = 140102000200 + $signToTextIndex1[$planets[1]['in_sign_id']];
            }
            if ($isPlanetsGoodPhaseNumMoreTwo[3]
                && in_array($planets[3]['in_house_id'], [1, 4, 7, 10], true)
                && in_array($planets[3]['in_sign_id'], [2, 4, 8, 12], true)
                && (!in_array(3, $earlyConds, true) || $planets[3]['ancient']['power'] > $planets[1]['ancient']['power']))
            {
                $earlyConds[] = 3;
                $text[0][3] = 140102000300 + $signToTextIndex1[$planets[3]['in_sign_id']];
            }
            // 第四，如果月亮或金星是落在第五宫或第七宫内。
            if (in_array($planets[1]['in_house_id'], [5, 7], true))
            {
                $earlyConds[] = 4;
                $text[0][4] = 140102000400 + ($planets[1]['in_house_id'] === 5 ? 0 : 1);
            }
            if (in_array($planets[3]['in_house_id'], [5, 7], true) && (!in_array(4, $earlyConds, true) || $planets[3]['ancient']['power'] > $planets[1]['ancient']['power']))
            {
                $earlyConds[] = 4;
                $text[0][4] = 140102000500 + ($planets[1]['in_house_id'] === 5 ? 0 : 1);
            }
            // 第六，如果金星和火星同时入庙，并且（金星或火星）之一具有两个以上的主吉相。
            if ($planets[3]['ancient']['walls'] === 1 && $planets[4]['ancient']['walls'] === 1
                && ($isPlanetsGoodPhaseNumMoreTwo[3] || $isPlanetsGoodPhaseNumMoreTwo[4]))
            {
                $earlyConds[] = 6;
                $text[0][6] = 1401020008;
            }

            /**
             * 晚婚逻辑判断
             */
            // 第三，如果月亮或金星被火星、土星、天王星、海王星或冥王星所刑克到，这些行星又正好是落在第五宫或第七宫内。
            $usePlanet = 0;
            if (in_array($planets[1]['in_house_id'], [5, 7], true))
            {
                if (isset($planets[1]['phase']['1-4']) && in_array($planets[1]['phase']['1-4']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 4;
                    $text[1][3] = 140102020200;
                }
                if (($usePlanet === 0 || $planets[6]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[1]['phase']['1-6']) && in_array($planets[1]['phase']['1-6']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 6;
                    $text[1][3] = 140102020201;
                }
                if (($usePlanet === 0 || $planets[7]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[1]['phase']['1-7']) && in_array($planets[1]['phase']['1-7']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 7;
                    $text[1][3] = 140102020202;
                }
                if (($usePlanet === 0 || $planets[8]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[1]['phase']['1-8']) && in_array($planets[1]['phase']['1-8']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 8;
                    $text[1][3] = 140102020203;
                }
                if (($usePlanet === 0 || $planets[9]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[1]['phase']['1-9']) && in_array($planets[1]['phase']['1-9']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 9;
                    $text[1][3] = 140102020204;
                }
            }
            if (in_array($planets[3]['in_house_id'], [5, 7], true))
            {
                if (isset($planets[3]['phase']['3-4']) && in_array($planets[3]['phase']['3-4']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 4;
                    $text[1][3] = 140102020300;
                }
                if (($usePlanet === 0 || $planets[6]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-6']) && in_array($planets[3]['phase']['3-6']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 6;
                    $text[1][3] = 140102020301;
                }
                if (($usePlanet === 0 || $planets[7]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-7']) && in_array($planets[3]['phase']['3-7']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 7;
                    $text[1][3] = 140102020302;
                }
                if (($usePlanet === 0 || $planets[8]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-8']) && in_array($planets[3]['phase']['3-8']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 8;
                    $text[1][3] = 140102020303;
                }
                if (($usePlanet === 0 || $planets[9]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-9']) && in_array($planets[3]['phase']['3-9']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 9;
                    $text[1][3] = 140102020304;
                }
            }
            // 第五，如果月亮或金星，与木星形成主凶相。
            if (isset($planets[1]['phase']['1-5']) && in_array($planets[1]['phase']['1-5']['phase_e'], [90, 180], true))
            {
                $laterConds[] = 5;
                $text[1][5] = 140102020600;
            }
            if (isset($planets[3]['phase']['3-5']) && in_array($planets[3]['phase']['3-5']['phase_e'], [90, 180], true) && (!in_array(5, $laterConds, true) || $planets[3]['ancient']['power'] < $planets[1]['ancient']['power']))
            {
                $laterConds[] = 5;
                $text[1][5] = 140102020601;
            }
            // 第六，如果第五宫或第七宫宫主星是落在白羊座、双子座、狮子座、处女座或摩羯座内，而且又具有凶相位。
            if (!empty($planets[$house7ProtectAncient]['phase'])
                && in_array($houses[7]['protect_ancient_insign_id'], [1, 3, 5, 6, 10], true))
            {
                $house7ProtectAncientBadPhase = false;
                foreach ($planets[$house7ProtectAncient]['phase'] as $phase_h_7)
                {
                    if ($house7ProtectAncientBadPhase === false && in_array($phase_h_7['phase_e'], [90, 180], true))
                    {
                        $house7ProtectAncientBadPhase = true;
                    }
                }
                if ($house7ProtectAncientBadPhase)
                {
                    $laterConds[] = 6;
                    $text[1][6] = 140102020800 + $signToTextIndex2[$houses[7]['protect_ancient_insign_id']];
                }
            }
            if (!empty($planets[$house5ProtectAncient]['phase'])
                && in_array($houses[5]['protect_ancient_insign_id'], [1, 3, 5, 6, 10], true) && !in_array(6, $laterConds, true))
            {
                $house5ProtectAncientBadPhase = false;
                foreach ($planets[$house5ProtectAncient]['phase'] as $phase_h_5)
                {
                    if ($house5ProtectAncientBadPhase === false && in_array($phase_h_5['phase_e'], [90, 180], true))
                    {
                        $house5ProtectAncientBadPhase = true;
                    }
                }
                if ($house5ProtectAncientBadPhase)
                {
                    $laterConds[] = 6;
                    $text[1][6] = 140102020700 + $signToTextIndex2[$houses[5]['protect_ancient_insign_id']];
                }
            }
            // 第七，如果第五宫或第七宫的宫头位置，是落在白羊座、狮子座、处女座或摩羯座。
            if (in_array($houses[7]['in_sign_id'], [1, 5, 6, 10], true))
            {
                $laterConds[] = 7;
                $text[1][7] = 140102021000 + $signToTextIndex3[$houses[7]['in_sign_id']];
            }
            if (in_array($houses[5]['in_sign_id'], [1, 5, 6, 10], true) && !in_array(7, $laterConds, true))
            {
                $laterConds[] = 7;
                $text[1][7] = 140102020900 + $signToTextIndex3[$houses[5]['in_sign_id']];
            }
            //第八，如果土星是落入天蝎座  或者  月亮落入天蝎座，同时与土星形成平行相位、合相或主凶相
            if ($planets[6]['in_sign_id'] === 8)
            {
                $laterConds[] = 8;
                $text[1][8] = 140102021100;
            }
            if ((in_array('1-6', $ajs, true)
                    || (isset($planets[1]['phase']['1-6'])
                        && in_array($planets[1]['phase']['1-6']['phase_e'], [0, 90, 180], true))) && (!in_array(8, $laterConds, true) || $planets[1]['ancient']['power'] < $planets[6]['ancient']['power']))
            {
                $laterConds[] = 8;
                $text[1][8] = 140102021101;
            }
            // 第九，如果月亮或金星是落入摩羯座，而且被刑克到
            if (($planets[1]['in_sign_id'] === 10 && !empty($planets[1]['phase'])))
            {
                $isMoonPhase90180 = false;
                foreach ($planets[1]['phase'] as $phase1)
                {
                    if ($isMoonPhase90180 === false && in_array($phase1['phase_e'], [90, 180], true))
                    {
                        $isMoonPhase90180 = true;
                    }
                }
                if ($isMoonPhase90180)
                {
                    $laterConds[] = 9;
                    $text[1][9] = 140102021200;
                }
            }
            if (($planets[3]['in_sign_id'] === 10 && !empty($planets[3]['phase'])))
            {
                $isVenuPhase90180 = false;
                foreach ($planets[3]['phase'] as $phase3)
                {
                    if ($isVenuPhase90180 === false && in_array($phase3['phase_e'], [90, 180], true))
                    {
                        $isVenuPhase90180 = true;
                    }
                }
                if ($isVenuPhase90180 && (!in_array(9, $laterConds, true) || $planets[3]['ancient']['power'] < $planets[1]['ancient']['power']))
                {
                    $laterConds[] = 9;
                    $text[1][9] = 140102021201;
                }
            }
            // 第十，如果月亮与太阳形成主凶相，而且月亮又正好是落在第一宫、第二宫、第三宫、第七宫、第八宫或第九宫内。
            if (isset($planets[0]['phase']['0-1']) && in_array($planets[0]['phase']['0-1']['phase_e'], [90, 180], true)
                && in_array($planets[1]['in_house_id'], [1, 2, 3, 7, 8, 9], true))
            {
                $laterConds[] = 10;
                $text[1][10] = 1401020213;
            }
            // 第十一，如果月亮正好是落在星座的最后度数上 (28 度～ 30 度 ) ，并且又缺乏相位关系，则时常会因为缺乏异性吸引力，而导致于婚姻有所延迟。
            if ($planets[1]['in_sign_deg_e'] >= 28 && empty($planets[1]['phase']))
            {
                $laterConds[] = 11;
                $text[1][11] = 1401020214;
            }
        }// 女
        else
        {
            $earlyCondsMax = 7;
            $laterCondsMax = 11;
            // 第一，如果她是在月盈 ( 从新月到满月 ) 的时段内出生，而且太阳又正好是落在第四宫、第五宫、第六宫、第十宫、第十一宫或第十二宫内。
            if (in_array($planets[0]['in_house_id'], [4, 5, 6, 10, 11, 12], true))
            {
                // 月盈
                if ($isWangxingMoon)
                {
                    $earlyConds[] = 1;
                    $text[0][1] = 1401020100;
                }
            }// 第一，如果她是在月亏 ( 从满月到新月 ) 的时段内出生，而且太阳又正好是落在第一宫、第二宫、第三宫、第七宫、第八宫或第九宫内。
            else
            {
                // 月亏
                if (!$isWangxingMoon)
                {
                    $laterConds[] = 1;
                    $text[1][1] = 1401020300;
                }
            }
            // 第三，如果太阳或金星是落在金牛座、巨蟹座、天蝎座或双鱼座内，并且与其他的行星形成两个以上的主吉相。
            if ($isPlanetsGoodPhaseNumMoreTwo[0] && in_array($planets[0]['in_sign_id'], [2, 4, 8, 12], true))
            {
                $earlyConds[] = 3;
                $text[0][3] = 140102010200 + $signToTextIndex1[$planets[0]['in_sign_id']];
            }
            if ($isPlanetsGoodPhaseNumMoreTwo[3] && in_array($planets[3]['in_sign_id'], [2, 4, 8, 12], true)
                && (!in_array(3, $earlyConds, true) || $planets[3]['ancient']['power'] > $planets[0]['ancient']['power']))
            {
                $earlyConds[] = 3;
                $text[0][3] = 140102010300 + $signToTextIndex1[$planets[3]['in_sign_id']];
            }
            // 第四，如果太阳、金星或火星是落在第五宫或第七宫内，并且具有两个以上的主吉相。
            $usePlanet = -1;
            if ($isPlanetsGoodPhaseNumMoreTwo[0])
            {
                if ($planets[0]['in_house_id'] === 7)
                {
                    $earlyConds[] = 4;
                    $usePlanet = 0;
                    $text[0][4] = 140102010401;
                } elseif ($planets[0]['in_house_id'] === 5)
                {
                    $earlyConds[] = 4;
                    $usePlanet = 0;
                    $text[0][4] = 140102010400;
                }
            }
            if ($isPlanetsGoodPhaseNumMoreTwo[3] && (!in_array(4, $earlyConds, true) || ($usePlanet === -1 && $planets[3]['ancient']['power'] > $planets[$usePlanet]['ancient']['power'])))
            {
                if ($planets[3]['in_house_id'] === 7)
                {
                    $earlyConds[] = 4;
                    $usePlanet = 3;
                    $text[0][4] = 140102010501;
                } elseif ($planets[3]['in_house_id'] === 5)
                {
                    $earlyConds[] = 4;
                    $usePlanet = 3;
                    $text[0][4] = 140102010500;
                }
            }
            if ($isPlanetsGoodPhaseNumMoreTwo[4] && (!in_array(4, $earlyConds, true) || ($usePlanet === -1 && $planets[4]['ancient']['power'] > $planets[$usePlanet]['ancient']['power'])))
            {
                if ($planets[4]['in_house_id'] === 7)
                {
                    $earlyConds[] = 4;
                    $usePlanet = 4;
                    $text[0][4] = 140102010601;
                } elseif ($planets[4]['in_house_id'] === 5)
                {
                    $earlyConds[] = 4;
                    $usePlanet = 4;
                    $text[0][4] = 140102010600;
                }
            }
            // 第六，如果太阳、金星和火星同时入庙，并且具有两个以上的主吉相。
            if ($planets[0]['ancient']['walls'] === 1 && $planets[3]['ancient']['walls'] === 1 && $planets[4]['ancient']['walls'] === 1
                && $isPlanetsGoodPhaseNumMoreTwo[0] && $isPlanetsGoodPhaseNumMoreTwo[3] && $isPlanetsGoodPhaseNumMoreTwo[4])
            {
                $earlyConds[] = 6;
                $text[0][6] = 1401020109;
            }

            /**
             * 晚婚逻辑判断
             */
            // 第三，如果太阳或金星被火星、土星、天王星、海王星或冥王星所刑克到，这些行星又正好是落在第五宫或第七宫内。
            $usePlanet = 0;
            if (in_array($planets[0]['in_house_id'], [5, 7], true))
            {
                if (isset($planets[0]['phase']['0-4']) && in_array($planets[0]['phase']['0-4']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 4;
                    $text[1][3] = 140102030200;
                }
                if (($usePlanet === 0 || $planets[6]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[0]['phase']['0-6']) && in_array($planets[0]['phase']['0-6']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 6;
                    $text[1][3] = 140102030201;
                }
                if (($usePlanet === 0 || $planets[7]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[0]['phase']['0-7']) && in_array($planets[0]['phase']['0-7']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 7;
                    $text[1][3] = 140102030202;
                }
                if (($usePlanet === 0 || $planets[8]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[0]['phase']['0-8']) && in_array($planets[0]['phase']['0-8']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 8;
                    $text[1][3] = 140102030203;
                }
                if (($usePlanet === 0 || $planets[9]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[0]['phase']['0-9']) && in_array($planets[0]['phase']['0-9']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 9;
                    $text[1][3] = 140102030204;
                }
            }
            if (in_array($planets[3]['in_house_id'], [5, 7], true)
                && (!in_array(3, $laterConds, true) || $planets[3]['ancient']['power'] < $planets[0]['ancient']['power']))
            {
                if (isset($planets[3]['phase']['3-4']) && in_array($planets[3]['phase']['3-4']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 4;
                    $text[1][3] = 140102030300;
                }
                if (($usePlanet === 0 || $planets[6]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-6']) && in_array($planets[3]['phase']['3-6']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 6;
                    $text[1][3] = 140102030301;
                }
                if (($usePlanet === 0 || $planets[7]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-7']) && in_array($planets[3]['phase']['3-7']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 7;
                    $text[1][3] = 140102030302;
                }
                if (($usePlanet === 0 || $planets[8]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-8']) && in_array($planets[3]['phase']['3-8']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 8;
                    $text[1][3] = 140102030303;
                }
                if (($usePlanet === 0 || $planets[9]['ancient']['power'] < $planets[$usePlanet]['ancient']['power'])
                    && isset($planets[3]['phase']['3-9']) && in_array($planets[3]['phase']['3-9']['phase_e'], [90, 180], true))
                {
                    $laterConds[] = 3;
                    $usePlanet = 9;
                    $text[1][3] = 140102030304;
                }
            }
            // 第五，如果月亮与金星 或者 月亮与木星，形成主凶相。同时满足那比较金木之间先天尊贵得分，选择得分低的，得分相同，选择金星。
            if (isset($planets[1]['phase']['1-5']) && in_array($planets[1]['phase']['1-5']['phase_e'], [90, 180], true))
            {
                $laterConds[] = 5;
                $text[1][5] = 140102030500;
            }
            if (isset($planets[3]['phase']['3-5']) && in_array($planets[3]['phase']['3-5']['phase_e'], [90, 180], true)
                && (!in_array(5, $laterConds, true) || $planets[3]['ancient']['power'] < $planets[1]['ancient']['power']))
            {
                $laterConds[] = 5;
                $text[1][5] = 140102030501;
            }
            // 第六，如果月亮或金星与天王星，形成平行相位、合相或主凶相。
            if (in_array('1-7', $ajs, true)
                || (isset($planets[1]['phase']['1-7'])
                    && in_array($planets[1]['phase']['1-7']['phase_e'], [0, 90, 180], true)))
            {
                $laterConds[] = 6;
                $text[1][6] = 140102030600;
            }
            if ((in_array('3-7', $ajs, true)
                    || (isset($planets[3]['phase']['3-7'])
                        && in_array($planets[3]['phase']['3-7']['phase_e'], [0, 90, 180], true)))
                && (!in_array(6, $laterConds, true) || $planets[3]['ancient']['power'] < $planets[1]['ancient']['power']))
            {
                $laterConds[] = 6;
                $text[1][6] = 140102030601;
            }
            // 第七，如果第五宫或第七宫宫主星是落在白羊座、双子座、狮子座、处女座或摩羯座内，而且又具有凶相位。 此处与男晚婚第六条一致
            if (!empty($planets[$house7ProtectAncient]['phase'])
                && in_array($houses[7]['protect_ancient_insign_id'], [1, 3, 5, 6, 10], true))
            {
                $house7ProtectAncientBadPhase = false;
                foreach ($planets[$house7ProtectAncient]['phase'] as $phase_h_7)
                {
                    if ($house7ProtectAncientBadPhase === false && in_array($phase_h_7['phase_e'], [90, 180], true))
                    {
                        $house7ProtectAncientBadPhase = true;
                    }
                }
                if ($house7ProtectAncientBadPhase)
                {
                    $laterConds[] = 7;
                    $text[1][7] = 140102030800 + $signToTextIndex2[$houses[7]['protect_ancient_insign_id']];
                }
            }
            if (!empty($planets[$house5ProtectAncient]['phase'])
                && in_array($houses[5]['protect_ancient_insign_id'], [1, 3, 5, 6, 10], true) && !in_array(7, $laterConds, true))
            {
                $house5ProtectAncientBadPhase = false;
                foreach ($planets[$house5ProtectAncient]['phase'] as $phase_h_5)
                {
                    if ($house5ProtectAncientBadPhase === false && in_array($phase_h_5['phase_e'], [90, 180], true))
                    {
                        $house5ProtectAncientBadPhase = true;
                    }
                }
                if ($house5ProtectAncientBadPhase)
                {
                    $laterConds[] = 7;
                    $text[1][7] = 140102030700 + $signToTextIndex2[$houses[5]['protect_ancient_insign_id']];
                }
            }

            // 第八，如果第五宫或第七宫的宫头位置，是落在白羊座、狮子座、处女座或摩羯座。
            if (in_array($houses[7]['in_sign_id'], [1, 5, 6, 10], true))
            {
                $laterConds[] = 8;
                $text[1][8] = 140102031000 + $signToTextIndex3[$houses[7]['in_sign_id']];
            }
            if (in_array($houses[5]['in_sign_id'], [1, 5, 6, 10], true) && !in_array(8, $laterConds, true))
            {
                $laterConds[] = 8;
                $text[1][8] = 140102030900 + $signToTextIndex3[$houses[5]['in_sign_id']];
            }
            // 第九，如果土星是落入天蝎座  或者  太阳落入天蝎座，同时与土星形成平行相位、合相或主凶相。
            if ($planets[6]['in_sign_id'] === 8)
            {
                $laterConds[] = 9;
                $text[1][9] = 140102031100;
            }
            if ((in_array('0-6', $ajs, true)
                    || (isset($planets[0]['phase']['0-6'])
                        && in_array($planets[0]['phase']['0-6']['phase_e'], [0, 90, 180], true))) && (!in_array(9, $laterConds, true) || $planets[0]['ancient']['power'] < $planets[6]['ancient']['power']))
            {
                $laterConds[] = 9;
                $text[1][9] = 140102031101;
            }
            // 第十，如果太阳或金星是落入摩羯座，而且被刑克到 // ，特别是如果被土星所刑克到。
            if (($planets[0]['in_sign_id'] === 10 && !empty($planets[0]['phase'])))
            {
                $isSunPhase90180 = false;
                foreach ($planets[0]['phase'] as $phase0)
                {
                    if ($isSunPhase90180 === false && in_array($phase0['phase_e'], [90, 180], true))
                    {
                        $isSunPhase90180 = true;
                    }
                }
                if ($isSunPhase90180)
                {
                    $laterConds[] = 10;
                    $text[1][10] = 140102031200;
                }
            }
            if (($planets[3]['in_sign_id'] === 10 && !empty($planets[3]['phase'])))
            {
                $isVenuPhase90180 = false;
                foreach ($planets[3]['phase'] as $phase3)
                {
                    if ($isVenuPhase90180 === false && in_array($phase3['phase_e'], [90, 180], true))
                    {
                        $isVenuPhase90180 = true;
                    }
                }
                if ($isVenuPhase90180 && (!in_array(10, $laterConds, true) || $planets[3]['ancient']['power'] < $planets[1]['ancient']['power']))
                {
                    $laterConds[] = 10;
                    $text[1][10] = 140102031201;
                }
            }
            // 第十一，如果月亮与太阳形成主凶相，而且太阳又正好是落在第一宫、第二宫、第三宫、第七宫、第八宫或第九宫内。
            if (isset($planets[0]['phase']['0-1']) && in_array($planets[0]['phase']['0-1']['phase_e'], [90, 180], true)
                && in_array($planets[0]['in_house_id'], [1, 2, 3, 7, 8, 9], true))
            {
                $laterConds[] = 11;
                $text[1][11] = 1401020313;
            }
            // TODO 第十二，如果太阳在离开它所落入的星座以前，缺乏与其他的行星形成相位关系。
//            if (empty($planets[0]['phase']))
//            {
//                $laterConds[] = 12;
//                $text[1][11] = 1401020314;
//            }
        }
        // 落在东半球的行星数量（日月水金火木土天海冥+北交）
        $planetAtEastNum = 0;
        foreach ($planets as $p)
        {
            // 10颗+北交点
            if ($p['id'] < 10 || $p['id'] === 12)
            {
                // 落在东半球
                if ($p['in_house_id'] > 3 && $p['in_house_id'] < 10)
                {
                    $planetAtEastNum++;
                }
            }
        }
        // 第二，如果50%以上的行星（10大行星+北交点），是落在东半球上。
        if ($planetAtEastNum > 5)
        {
            // 条件2，男女一致
            $earlyConds[] = 2;
            if ($recodeSex === 1)
            {
                $text[0][2] = 1401020001;
            } else
            {
                $text[0][2] = 1401020101;
            }
        } else
        {
            $laterConds[] = 2;
            if ($recodeSex === 1)
            {
                $text[1][2] = 1401020201;
            } else
            {
                $text[1][2] = 1401020301;
            }
        }
        /**
         * 条件5，男女早婚一致
         * 第五，如果第五宫或第七宫的宫头位置，是落在金牛座、巨蟹座、天蝎座或双鱼座。
         * 两个条件同时满足时，优先选择7宫
         */
        if (in_array($houses[7]['in_sign_id'], [2, 4, 8, 12], true))
        {
            $earlyConds[] = 5;
            if ($recodeSex === 1)
            {

                $text[0][5] = 140102000700 + $signToTextIndex1[$houses[7]['in_sign_id']];
            } else
            {
                $text[0][5] = 140102010800 + $signToTextIndex1[$houses[7]['in_sign_id']];
            }
        }
        if (!in_array(5, $earlyConds, true) && in_array($houses[5]['in_sign_id'], [2, 4, 8, 12], true))
        {
            $earlyConds[] = 5;
            if ($recodeSex === 1)
            {
                $text[0][5] = 140102000600 + $signToTextIndex1[$houses[5]['in_sign_id']];
            } else
            {
                $text[0][5] = 140102010700 + $signToTextIndex1[$houses[5]['in_sign_id']];
            }
        }

        /**
         * 条件7，男女早婚一致
         * 第七，如果金星或木星是落入第七宫内，并且具有两个以上的主吉相。
         */
        if ($planets[3]['in_house_id'] === 7 && $isPlanetsGoodPhaseNumMoreTwo[3])
        {
            $earlyConds[] = 7;
            if ($recodeSex === 1)
            {
                $text[0][7] = 1401020009;
            } else
            {
                $text[0][7] = 1401020010;
            }
        }
        if ($planets[5]['in_house_id'] === 7 && $isPlanetsGoodPhaseNumMoreTwo[5] && (!in_array(7, $earlyConds, true) || $planets[5]['ancient']['power'] > $planets[3]['ancient']['power']))
        {
            $earlyConds[] = 7;
            if ($recodeSex === 1)
            {
                $text[0][7] = 1401020110;
            } else
            {
                $text[0][7] = 1401020111;
            }
        }
        //以上各种征象的条件显示，每条占比1/7，计算可能早婚几率数字。

        /**
         * 晚婚几率
         * 条件4，男女晚婚判断一致
         */
        //第四，如果火星、土星、天王星、海王星或冥王星是落入第五宫或第七宫内，并且具有凶相位。
        $isPlanetBadPhase = [4 => false, 6 => false, 7 => false, 8 => false, 9 => false];
        $usePlanet = 0;
        foreach ($isPlanetBadPhase as $p => $isPBP)
        {
            if (!empty($planets[$p]['phase']))
            {
                foreach ($planets[$p]['phase'] as $phase)
                {
                    if ($isPlanetBadPhase[$p] === false && $phase['id'] < 10 && in_array($phase['phase_e'], [90, 180], true))
                    {
                        $isPlanetBadPhase[$p] = true;
                    }
                }
            }
            // 具有凶相位，且落在5/7宫
            if ($isPlanetBadPhase[$p])
            {
                if ($planets[$p]['in_house_id'] === 7 && ($usePlanet === 0 || $planets[$usePlanet]['in_house_id'] !== 7 || $planets[$p]['ancient']['power'] < $planets[$usePlanet]['ancient']['power']))
                {
                    $laterConds[] = 4;
                    $usePlanet = $p;
                    if ($recodeSex === 1)
                    {
                        $text[1][4] = 140102020500 + $planetToTextIndex1[$p];
                    } else
                    {
                        $text[1][4] = 14010203040001 + $planetToTextIndex1[$p] * 100;
                    }

                } elseif ($planets[$p]['in_house_id'] === 5 && ($usePlanet === 0 || $planets[$p]['ancient']['power'] < $planets[$usePlanet]['ancient']['power']))
                {
                    $laterConds[] = 4;
                    $usePlanet = $p;
                    if ($recodeSex === 1)
                    {
                        $text[1][4] = 140102020400 + $planetToTextIndex1[$p];
                    } else
                    {
                        $text[1][4] = 14010203040000 + $planetToTextIndex1[$p] * 100;
                    }
                }
            }
        }

        //1、计算
        //早婚率=50%+50%*（命中条数/总条数）
        //晚婚率=50%+50%*（命中条数/总条数）
        $earlyCondsCount = count(array_unique($earlyConds));
        $laterCondsCount = count(array_unique($laterConds));
        $earlyProbability = 0.5 + 0.5 * ($earlyCondsCount / $earlyCondsMax);
        $laterProbability = 0.5 + 0.5 * ($laterCondsCount / $laterCondsMax);
        /**
         * 早晚婚判断  0=>早婚,1=>晚婚
         */
        $type = $earlyProbability > $laterProbability ? 0 : 1;
        //2、判断早婚几率和晚婚几率高的一个，抛弃另外一个。
        //3、用1-早婚率=晚婚率，反之亦然
        //4、制作一个百分比图形，可以是饼图
        // 语料按照顺序，调用前两段话
        ksort($text[$type]);
        $tags[] = array_shift($text[$type]);
        $tags[] = array_shift($text[$type]);

        $result = [
            'desc' => '主题 2：婚姻特质',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 婚姻报告 主题3：什么在阻碍你姻缘
     * @return array
     */
    protected function getDatingReportSection2(): array
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];

        // 星座间相位
        $phaseSign = [
            1 => [90 => 4, 270 => 10],
            2 => [90 => 5, 270 => 11],
            3 => [90 => 6, 270 => 12],
            4 => [90 => 7, 270 => 1],
            5 => [90 => 8, 270 => 2],
            6 => [90 => 9, 270 => 3],
            7 => [90 => 10, 270 => 4],
            8 => [90 => 11, 270 => 5],
            9 => [90 => 12, 270 => 6],
            10 => [90 => 1, 270 => 7],
            11 => [90 => 2, 270 => 8],
            12 => [90 => 3, 270 => 9]
        ];
        // 土星落星座年份
        $satuSignYear = [
            1 => [1908, 1909, 1938, 1939, 1967, 1968, 1996, 1997, 1998, 1996, 1997, 2025, 2026, 2027, 2055, 2056, 2057, 2085, 2086],
            2 => [1910, 1911, 1912, 1940, 1941, 1969, 1970, 1998, 1999, 2000, 2028, 2029, 2058, 2059, 2087, 2088, 2089],
            3 => [1913, 1914, 1942, 1943, 1944, 1971, 1972, 1973, 2001, 2002, 2030, 2031, 2032, 2060, 2061, 2090, 2091],
            4 => [1915, 1916, 1917, 1945, 1946, 1974, 1975, 2003, 2004, 2033, 2034, 2062, 2063, 2064, 2092, 2093],
            5 => [1918, 1919, 1947, 1948, 1976, 1977, 2005, 2006, 2035, 2036, 2037, 2065, 2066, 2094, 2095, 2096],
            6 => [1890, 1891, 1892, 1920, 1921, 1922, 1949, 1950, 1951, 1978, 1979, 1980, 2007, 2008, 2009, 2038, 2039, 2067, 2068, 2069, 2097, 2098],
            7 => [1893, 1894, 1895, 1923, 1924, 1952, 1953, 1981, 1982, 1983, 2010, 2011, 2012, 2040, 2041, 2042, 2070, 2071, 2099, 2100],
            8 => [1896, 1897, 1925, 1926, 1927, 1954, 1955, 1956, 1984, 1985, 2013, 2014, 2043, 2044, 2072, 2073, 2074, 2101, 2102, 2103],
            9 => [1898, 1899, 1928, 1929, 1957, 1958, 1986, 1987, 2015, 2016, 2017, 2045, 2046, 2047, 2075, 2076, 2104, 2105],
            10 => [1900, 1901, 1902, 1930, 1931, 1932, 1959, 1960, 1961, 1988, 1989, 1990, 2018, 2019, 2020, 2048, 2049, 2077, 2078, 2079, 2106, 2107, 2108],
            11 => [1903, 1904, 1905, 1933, 1934, 1962, 1963, 1991, 1992, 1993, 2021, 2022, 2050, 2051, 2052, 2080, 2081, 2109, 2110],
            12 => [1906, 1907, 1935, 1936, 1937, 1964, 1965, 1966, 1994, 1995, 2023, 2024, 2053, 2054, 2082, 2083, 2084],
        ];

        $startYear = $this->recode['year'] - 10;
        $endYear = $this->recode['year'] + 10;

//        $recode = $this->recode;
//        $recode['year'] = $startYear;
//        $recode['month'] = 6;
//        $recode['day'] = 15;
//        $recode['hour'] = 12;
//        $recode['minute'] = 30;
//        $astrologPrefix = config('astrolog.prefix');
//        $years1 = [];
//        $years2 = [];
//        $p2 = $planets[2]['deg'];// 自己的水星的度数
//        $p3 = $planets[3]['deg'];// 自己的金星的度数
//        $p2Orb = $this->setting4['natal']['planets'][2];
//        $p3Orb = $this->setting4['natal']['planets'][3];
//        $p6Orb = $this->setting4['natal']['planets'][6];
//        for ($i = $startYear; $i <= $endYear; $i++)
//        {
//            $recode['year'] = $i;
//            // 土星的度数
//            $p6 = Astrolog::getInstance()->setExecPrefix($astrologPrefix)
//                    ->getPlanetOriginData('6', $recode)[0] * 1;
//
//        }
        //1、调用与自己太阳90 度的星座（2 个星座）
        //固定语：跟你性格不合的类型是：XX 星座成分较重的人，
        // 140200000000 140200000100
        $sunInSign = ($planets[0]['in_sign_id'] - 1) * 100;
        $tags[] = 140200000000 + $sunInSign;
        $tags[] = 140200000000 + $sunInSign + 1;
        $levels[0] = [$phaseSign[$planets[0]['in_sign_id']][90], $phaseSign[$planets[0]['in_sign_id']][270]];
        //2、调用与自己金星 90度的土星星座（2 个星座）对应 4 分，取土星年份（前后 10 年内）
        //固定语：跟你感情不契合的类型是：出生年在XX 年份的人，
        $venuInappropriate1 = $phaseSign[$planets[3]['in_sign_id']][90];
        $venuInappropriate2 = $phaseSign[$planets[3]['in_sign_id']][270];
        $year1 = [];
        $year1 = array_merge($year1, $satuSignYear[$venuInappropriate1], $satuSignYear[$venuInappropriate2]);
        $levels[1] = [];
        foreach ($year1 as $y1)
        {
            if ($y1 >= $startYear && $y1 <= $endYear && !in_array($y1, $levels[1], false))
            {
                $levels[1][] = $y1;
            }
        }
        $textTag = [4, 2, 3, 1];
        // 金星火象1，调用3 分词条
        // 金星土象2，调用4 分词条
        // 金星风象3，调用2 分词条
        // 金星水象0，调用5 分词条
        $tags[] = 1402000200 + $textTag[$planets[3]['in_sign_id'] % 4];
        //3、调用与自己水星 90 度的土星星座（2 个星座）对应 4 分，取土星年份（前后 10 年内）
        //固定语：跟你无法沟通的类型是：出生在 XX 年份的人，
        $mercInappropriate1 = $phaseSign[$planets[2]['in_sign_id']][90];
        $mercInappropriate2 = $phaseSign[$planets[2]['in_sign_id']][270];
        $year2 = array_merge($satuSignYear[$mercInappropriate1], $satuSignYear[$mercInappropriate2]);
        $levels[2] = [];
        foreach ($year2 as $y2)
        {
            if ($y2 >= $startYear && $y2 <= $endYear && !in_array($y2, $levels[2], false))
            {
                $levels[2][] = $y2;
            }
        }
        // 水星火象1，调用3 分词条
        // 水星土象2，调用4 分词条
        // 水星风象3，调用2 分词条
        // 水星水象0，调用5 分词条
        $tags[] = 1402000500 + $textTag[$planets[2]['in_sign_id'] % 4];

        //②错过婚缘的因素+影响星级 3000字
        //1、默认调取不会错过姻缘语料
        //按照第五宫星座类型写12个，100字=1200字
        $house5InSign = $houses[5]['in_sign_id'];
//        $tags[] = 1402010000 + $house5InSign - 1;
        //2、错过的情况
        $tags[] = 1402010100 + $house5InSign - 1;
        //第五宫宫主落入十二宫，按照五个等级写 6000字
        $house5ProtectAncient = $houses[5]['protect_ancient_id'];
        $house5ProtectAncientInHouse = $planets[$house5ProtectAncient]['in_house_id'];
        $house5ProtectAncientPower = $planets[$house5ProtectAncient]['ancient']['power'];
        //等级按照五宫主，先天尊贵得分
        //-3分以下，5
        //-3-0，4
        //0分以上3
        //0-3，2
        //5分以上1
        if ($house5ProtectAncientPower < -3)
        {
            $state2 = 5;
        } elseif ($house5ProtectAncientPower < 0)
        {
            $state2 = 4;
        } elseif ($house5ProtectAncientPower < 3)
        {
            $state2 = 3;
        } elseif ($house5ProtectAncientPower < 5)
        {
            $state2 = 2;
        } else
        {
            $state2 = 1;
        }
        if ($state2 < 4)
        {
            $tags[] = 140201020000 + ($house5ProtectAncientInHouse - 1) * 100 + $state2 - 1;
        }
        $result = [
            'desc' => '主题3：什么在阻碍你姻缘',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 婚姻报告 主题4：结婚对象条件如何
     * @return array
     */
    protected function getDatingReportSection3(): array
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];

        //①性格特征 8000字
        //婚神星星座，100*12*5
        $junoInSign = $planets[13]['in_sign_id'];
        $tags[] = 1403000000 + $junoInSign - 1;

        //  婚神星有一个负面相位-1
        //  婚神星有一个正面相位+1
        //  合相按照行星尊贵，正分+1 负分-1
        if (!empty($planets[13]['phase']))
        {
            $goodPhase = null;
            $badPhase = null;
            $maxPower = null;
            $minPower = null;
            foreach ($planets[13]['phase'] as $phase)
            {
                if ($phase['id'] < 10)
                {
                    // 成相星体尊贵得分
                    $phaseIdPower = $planets[$phase['id']]['ancient']['power'];
                    // 正面相位
                    if (in_array($phase['phase_e'], [60, 120]))
                    {
                        if ($maxPower === null || $phaseIdPower > $maxPower)
                        {
                            $goodPhase = $phase['id'];
                            $maxPower = $phaseIdPower;
                        }
                    }// 负面相位
                    elseif (in_array($phase['phase_e'], [90, 180]))
                    {
                        if ($minPower === null || $phaseIdPower < $minPower)
                        {
                            $badPhase = $phase['id'];
                            $minPower = $phaseIdPower;
                        }
                    }// 合相判断成相星体先天尊贵得分
                    elseif ($phase['phase_e'] === 0)
                    {
                        // // 正面相位
                        if ($phaseIdPower >= 0)
                        {
                            if ($maxPower === null || $phaseIdPower > $maxPower)
                            {
                                $goodPhase = $phase['id'];
                                $maxPower = $phaseIdPower;
                            }
                        }// 负面相位
                        else
                        {
                            if ($minPower === null || $phaseIdPower < $minPower)
                            {
                                $badPhase = $phase['id'];
                                $minPower = $phaseIdPower;
                            }
                        }
                    }
                }
            }
            // 婚神星相位（10个行星正负），10*2*100=2000字
            // 如果没有相位，不输出
            // 如果一个相位，输出这一个
            // 超过2个，输出正面得分最强行星+负面最弱行星。
            if ($goodPhase !== null)
            {
                $tags[] = 140300010000 + $goodPhase * 100;
            }
            if ($badPhase !== null)
            {
                $tags[] = 140300010001 + $badPhase * 100 + 1;
            }
        }

        //②经济能力 3500字
        //第八宫宫主星得分
        $house8ProtectAncient = $houses[8]['protect_ancient_id'];
        $house8ProtectAncientPower = $planets[$house8ProtectAncient]['ancient']['power'];
        //5分=得分高于5分
        //4分=得分3-5
        //3分=得分大于0
        //2分=得分大于-3
        //1分=低于-3
        //如果福点在此宫，直接+5
        if ($planets[14]['in_house_id'] === 8)
        {
            $house8ProtectAncientPower += 5;
        }
        //七个行星分五档
        if ($house8ProtectAncientPower >= 5)
        {
            $state2 = 5;
        } elseif ($house8ProtectAncientPower >= 3)
        {
            $state2 = 4;
        } elseif ($house8ProtectAncientPower >= 0)
        {
            $state2 = 3;
        } elseif ($house8ProtectAncientPower >= -3)
        {
            $state2 = 2;
        } else
        {
            $state2 = 1;
        }
        // 七个行星分五档
        $tags[] = 1403010000 + $house8ProtectAncient * 100 + $state2 - 1;

        //③事业特质2400字
        // 第四宫落入星座
        $house4InSign = $houses[4]['in_sign_id'];
        $tags[] = 1403020000 + $house4InSign - 1;
        //12宫落入星座
        $house12InSign = $houses[12]['in_sign_id'];
        $tags[] = 1403020100 + $house12InSign - 1;

        //④家庭背景 3500字
        //第十宫宫主星得分
        $house10ProtectAncient = $houses[10]['protect_ancient_id'];
        $house10ProtectAncientPower = $planets[$house10ProtectAncient]['ancient']['power'];
        //5分=得分高于5分
        //4分=得分3-5
        //3分=得分大于0
        //2分=得分大于-3
        //1分=低于-3
        //如果福点在此宫，直接+5
        if ($planets[14]['in_house_id'] === 10)
        {
            $house10ProtectAncientPower += 5;
        }
        if ($house10ProtectAncientPower >= 5)
        {
            $state3 = 5;
        } elseif ($house10ProtectAncientPower >= 3)
        {
            $state3 = 4;
        } elseif ($house10ProtectAncientPower >= 0)
        {
            $state3 = 3;
        } elseif ($house10ProtectAncientPower >= -3)
        {
            $state3 = 2;
        } else
        {
            $state3 = 1;
        }
        $tags[] = 1403030000 + $house10ProtectAncient * 100 + $state3 - 1;

        //⑤相识途径 2700字
        //这个没有打分
        //婚神星落入宫位，100字*12
        $tags[] = 1403040000 + $planets[13]['in_house_id'] - 1;
        //第七宫宫主星，落入星座
        $tags[] = 1403040100 + $houses[7]['protect_ancient_id'];

        $result = [
            'desc' => '主题4：结婚对象条件如何',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    /**
     * 婚姻报告 主题5：建议改为结婚几率最大时间什么时候会结婚
     * @return array
     */
    protected function getDatingReportSection4($curvData = []): array
    {
        $tags = $levels = [];

        //①最容易结婚的十年姻缘年份 （图）
        //按照主题 1得分选择十个最佳年份
        $sortData = [];
        $start = 20;
        foreach ($curvData as $k => $d)
        {
            $sortData[] = [
                'y' => $start,
                's' => $d
            ];
            $start++;
        }
        $sortData = resort($sortData, 's', 'DESC');
        $levels = array_slice($sortData, 0, 10);
        $levels = resort($levels, 'y', 'ASC');

        $result = [
            'desc' => '主题5：建议改为结婚几率最大时间什么时候会结婚',
            'content_list' => $tags,
            'levels' => json_encode($levels, true)
        ];
        return $result;
    }

    /**
     * 婚姻报告 主题6：婚后感情如何
     * @return array
     */
    protected function getDatingReportSection5(): array
    {
        $tags = $levels = [];
        $planets = $this->astroData['planets'];
        $houses = $this->astroData['houses'];
        //①婚后感情相处模式+影响星级 3500字
        //第七宫宫主星得分
        $house7ProtectAncient = $houses[7]['protect_ancient_id'];
        $house7ProtectAncientInSign = $planets[$house7ProtectAncient]['in_sign_id'];
        $house7ProtectAncientPower = $planets[$house7ProtectAncient]['ancient']['power'];
        //如果福点在此宫，直接+5
        if ($planets[14]['in_house_id'] === 10)
        {
            $house7ProtectAncientPower += 5;
        }
        //5分=得分高于5分
        //4分=得分3-5
        //3分=得分大于0
        //2分=得分大于-3
        //1分=低于-3
        if ($house7ProtectAncientPower >= 5)
        {
            $state1 = 5;
        } elseif ($house7ProtectAncientPower >= 3)
        {
            $state1 = 4;
        } elseif ($house7ProtectAncientPower >= 0)
        {
            $state1 = 3;
        } elseif ($house7ProtectAncientPower >= -3)
        {
            $state1 = 2;
        } else
        {
            $state1 = 1;
        }
        $tags[] = 1405000000 + ($house7ProtectAncientInSign - 1) * 100 + $state1 - 1;

        //②婚后经济是否富裕+影响星级
        //第二宫宫主+第八宫宫主，计算平均分
        $house2ProtectAncient = $houses[2]['protect_ancient_id'];
        $house2ProtectAncientPower = $planets[$house2ProtectAncient]['ancient']['power'];
        $house8ProtectAncient = $houses[8]['protect_ancient_id'];
        $house8ProtectAncientPower = $planets[$house8ProtectAncient]['ancient']['power'];
        if ($house8ProtectAncientPower > $house2ProtectAncientPower)
        {
            //如果福点在第二或者第八宫，分别直接+5
            if ($planets[14]['in_house_id'] === 8)
            {
                $house8ProtectAncientPower += 5;
            }
            if ($house8ProtectAncientPower >= 5)
            {
                $state3 = 5;
            } elseif ($house8ProtectAncientPower >= 3)
            {
                $state3 = 4;
            } elseif ($house8ProtectAncientPower >= 0)
            {
                $state3 = 3;
            } elseif ($house8ProtectAncientPower >= -3)
            {
                $state3 = 2;
            } else
            {
                $state3 = 1;
            }
            $tags[] = 140501010000 + $house8ProtectAncient * 100 + $state3 - 1;
        } else
        {
            //如果福点在第二或者第八宫，分别直接+5
            if ($planets[14]['in_house_id'] === 2)
            {
                $house2ProtectAncientPower += 5;
            }
            if ($house2ProtectAncientPower >= 5)
            {
                $state2 = 5;
            } elseif ($house2ProtectAncientPower >= 3)
            {
                $state2 = 4;
            } elseif ($house2ProtectAncientPower >= 0)
            {
                $state2 = 3;
            } elseif ($house2ProtectAncientPower >= -3)
            {
                $state2 = 2;
            } else
            {
                $state2 = 1;
            }
            $tags[] = 140501000000 + $house2ProtectAncient * 100 + $state2 - 1;
        }
        //③婚后是否会有第三者
        // 调用第七宫落入星座
        $tags[] = 1405020000 + $house7ProtectAncientInSign - 1;

        //④婚后感情矛盾点及建议
        //按照太阳月亮金星火星水星的顺序，最多显示3个 词条。
        $condNum2 = 0;
        //不够自信，日先天负分 300
        if ($planets[0]['ancient']['power'] < 0 && $planets[0]['ancient']['migration'] !== 1)
        {
            $tags[] = 14050300;
            $condNum2++;
        }
        // 情绪问题，月负面相位 300
        if (!empty($planets[1]['phase']))
        {
            $hasBadPhase = false;
            foreach ($planets[1]['phase'] as $phase)
            {
                if (in_array($phase['phase_e'], [90, 180], false))
                {
                    $hasBadPhase = true;
                } elseif ($phase['phase_e'] === 0)
                {
                    if ($planets[$phase['id']]['ancient']['power'] < 0)
                    {
                        $hasBadPhase = true;
                    }
                }
            }
            if ($hasBadPhase)
            {
                $tags[] = 14050301;
                $condNum2++;
            }
        }
        //三观问题，金星先天负分（2个星座）600
        if ($planets[3]['ancient']['power'] < 0 && $planets[3]['ancient']['migration'] !== 1)
        {
            if ($condNum2 < 3)
            {
                $tags[] = 14050303;
                $condNum2++;
            }
        }
        //失去活力，火星负分（2个星座）600
        if ($planets[4]['ancient']['power'] < 0 && $planets[4]['ancient']['migration'] !== 1)
        {
            if ($condNum2 < 3)
            {
                $tags[] = 14050304;
                $condNum2++;
            }
        }
        //沟通问题，水星先天负分（2个星座）600
        if ($planets[2]['ancient']['power'] < 0 && $planets[2]['ancient']['migration'] !== 1)
        {
            if ($condNum2 < 3)
            {
                $tags[] = 14050302;
            }
        }

        $result = [
            'desc' => '主题6：婚后感情如何',
            'content_list' => $tags,
            'levels' => $levels
        ];
        return $result;
    }

    private function modSign($sign, $min = 1, $max = 12)
    {
        $mulriple = ($sign / 12);
        $mulriple += $mulriple;
        if ($sign < $min)
        {
            $sign += $mulriple * 12;
        } elseif ($sign > $max)
        {
            $sign -= $mulriple * 12;
        }
        return $sign;
    }
}